Data Migration Parse to Firebase. Directions - parse-platform

My app currently uses Parse and it's time to migrate. I am either considering hosting my own Parse Server or use Firebase. I am looking for guidance on how to approach my data migration problem to Firebase based on my current data model.
I have a table Users and that table, aside from all the normal columns, has Partner column which is of type User.
The flow, works like this:
User 1 signs up
User 1 invites User 2
User 2 receives invite e-mail with invite code
User 2 goes to app and signs-up using that code
And then I have a Parse cloud function that joins both users as partners adding each other's IDs to the respective column.
The partners are connected via a GCM topic name, so I can push notifications just to these two people.
So this is what I would like to achieve in Firebase. I would like to have two users to connect together in a way.
Maybe I could have a json like this:
partners: {
topic_name_partner1: {
user1: {info about user1},
user2: {info about user2}
},
topic_name_partner2: {
user1: {info about user1},
user2: {info about user2}
},
topic_name_partner3: {
user1: {info about user1},
user2: {info about user2}
}
....etc
}
Would this approach make sense ? Obviously I want a scalable application, so looking for help as well to best represent the data in that sense.
And, lastly, does Firebase have Cloud Functions like Parse? If not, how can I connect both users when the second user is registering? Maybe I have to look up Ref for the topic_name_partner1 string and then when finding it, update user2 with the reference to that user?
Thanks!

Based on this firebase structure guide, here is what I will do
users: {
user1: {
name: "user1",
partner: "topic_name_partner1",
... other info
},
user2: {
name: "user2",
partner: "topic_name_partner1",
... other info
},
user3: {
name: "user3",
partner: "topic_name_partner2",
... other info
}
}
partners: {
topic_name_partner1: {
user1: true,
user2: true
},
topic_name_partner2: {
user3: true
}
}
so the data will not so big when I just want to get a list of users in a partner without their details.
and currently Firebase does not have Cloud Functions feature like Parse, so you have to move the data from the client (or probably use their Firebase SDK for server).

Related

How to list all user workspaces using slack api?

After we get the user access token using Sign in with slack, we can query identity information as shown below:
{
ok: true,
user: {
name: 'arbxxxxxxx',
id: 'U0XXXXXXX',
email: 'arbxxxxxxx#xxxxxxx.com'
},
team: { id: 'T0XXXXXXX' },
response_metadata: {
scopes: [ 'identity.basic', 'identity.email', 'openid' ],
acceptedScopes: [ 'identity.basic' ]
}
}
The current workspace is team: { id: 'T0XXXXXXX' }.
How can I get all the other workspaces?
FYI: Sign in and acces token usage is shown in at this gist: https://gist.github.com/seratch/92bf98679d7a37a87dfa7376d02a51a1
With the exception of Org Apps installed on a Grid, users actually auth per workspace, and each is a unique identity, there's no real concept of a single identity that spans across workspaces

How do I mention a Bot (not a user) using CardFactory.adaptiveCard (NodeJS) in a post to a channel

I've scoured all four corners of interweb trying to find documentation on how to do this. But my journey has been unsuccessful so far. Part way through the search, I was able to find out how to mention a User (not a bot), and that was even a pain to find. I found that you have to post a field named msteams at the top level of the "any" object parameter which is an object consisting of an entities array. That array is an array of objects. The following use of adaptiveCard works when mentioning a user with the proper values replacing username and userID:
CardFactory.adaptiveCard({
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
type: 'AdaptiveCard',
msteams: {
entites: [
{
type: 'mention',
text: '<at>(username)</at>',
mentioned: {
id: <userID>,
name: <username>,
role: 'user'
}
}
]
}
body: [
{
type: 'TextBlock',
text: '<at>(userName)</at>',
}
]
});
The documentation of CardFactory.adaptiveCard just lists the parameter as an any Object and gives a small example not displaying an exhaustive list of fields of this parameter. It also posts a link to the Adaptive Card documentation, but that's what it's abstracting and the fields are not 1:1 (point and case this msteams object that is never referenced in the Adaptive Card documentation from what I can tell). I want to mention the bot itself that is posting this Adaptive Card. I've attempted to replace the mentioned object with the following
{
"id": "a3216960-131c-11eb-xxxx-xxxxxxxxx",
"name": "Bot",
"role": "bot"
}
This is equivalent to the object that I'm using to mention the "from" user in the adaptive card. But this is the recipient. The from user which is successfully mentioned is formatted like the following:
{
"id": "c3370a7c-95f2-4a60-xxxx-xxxxxxxxx",
"name": "User",
"role": "user"
}
Any help/guidance, tips, references would be greatly appreciated!
Currently #mention a bot in Adaptive card is not supported. You can #mention user in Adaptive card.

AWS Amplify GraphQL filter by dynamic Cognito User Group

Given the following AWS Amplify GraphQL Schema (schema.graphql):
type Organization
#model
#auth(rules: [
{ allow: groups, groups: ["Full-Access-Admin"], mutations: [create, update, delete], queries: [list, get] },
{ allow: owner },
{ allow: groups, groupsField: "orgAdminsCognitoGroup", mutations: null, queries: [list, get] }
]) {
id: ID!
name: String!
address: String!
industry: [String]!
owner: String
orgAdminsCognitoGroup: String
}
I can filter out all organizations except the ones that belong to the current authenticated user via the following:
res = await API.graphql(graphqlOperation(listOrganizations, {
// todo: filter by owner OR by is org admin
filter: {
owner: {
eq: this.props.currentUser.username
}
}
}));
but is there anyway to also filter by the orgAdminsCognitGroup which is a dynamic group in Cognito belonging to the organization? I have not found any success trying to use an additional #model to help with the #auth rules to protect each entity.
So, the question is wanting to filter groups that the user is either the owner of, or in the 'orgAdminsCognitoGroup'?
I think it's possible, though I don't think the best way is what you had in mind. Instead, I might recommend you set up a response mapping template that does some server side filtering for you.
Specifically, you would first get the groups from the current user's auth token:
#set($claimPermissions = $ctx.identity.claims.get("cognito:groups"))
Then you could iterate over every organization in the results. If any have an owner that is the current user, add them to a response list. If they aren't, continue to check the orgAdminsCognitoGroup. You'd do that by checking whether or not $claimPermissions contains the group that the orgAdmin is set to for that organization. If it is contained, add it to the response list. If not, ignore it and continue iterating.
It would be possible, theoretically, to do this client side with the token the user has signed in with. Much in the same way the response mapping template did it, the groups the user is in are inside the token. If you crack it open and pull out the groups, you could apply the filtering there. I would recommend not doing this for security reasons, though it is possible.

Linking 3 types of document for a view

I'm struggling with linked documents when creating a view.
A salesperson has multiple clients, each client has multiple
purchases.
I need to get a view containing:
salesperson ids for each client purchase.
In a relational database I would join:
purchase.clientid -> client._id
client.salesperson -> salesperson._id
Given:
{ _id: "1", type: "purchase", clientid: "2", items: [] }
{ _id: "2", type: "client", salespersonid: "3", name: "Chris the client" }
{ _id: "3", type: "salesperson", name: "Simon the salesperson" }
I've tried reading a lot of stuff, but nothing has clicked. How would I do this in a view?
{
_id: 'purchase-client-2-<unique-purchase-id>',
salespersonId: 'sales-3'
}
{
_id: 'sales-3',
name: 'Simon the salesperson'
}
{
_id: 'client-2',
name: 'Chris the client'
}
With the above documents you could query for all documents starting with 'purchase-client2' to get an array of purchase document. Each purchase document then tells you who the sales person was. Depending on the number of sales staff you may already have everything you need right there, assuming your map of sales id to name is already in memory.
If not, you could do a further lookup (and potentially cache that result). If that in-memory lookup or extra lookup doesn't work for you you could also duplicating the sales person's name in the purchase document. After all, NoSQL DB's don't follow the same rules as relational DB's and it's ok to duplicate now and again. You just have to think about how you keep the dups sync'ed up later.
If you can use and abuse the ID field and getaway without views then you may be better off. Views bring their own set of problems. Good luck!

Where to munge websocket data in Ember Data

I'm writing a web socket service for my Ember app. The service will subscribe to a URL, and receive data. The data will push models into Ember Data's store.
The URL scheme does not represent standard RESTful routes; it's not /posts and /users, for example, it's something like /inbound. Once I subscribe it will just be a firehose of various events.
For each of these routes I subscribe to, I will need to implementing data munging specific to that route, to get the data into a format Ember Data expects. My question is, where is the best place to do this?
An example event object I'll receive:
event: {
0: "device:add",
1: {
device: {
devPath: "/some/path",
label: "abc",
mountPath: "/some/path",
serial: "abc",
uuid: "5406-12F6",
uniqueIdentifier: "f5e30ccd7a3d4678681b580e03d50cc5",
mounted: false,
files: [ ],
ingest: {
uniqueIdentifier: 123
someProp: 123,
anotherProp: 'abc'
}
}
}
}
I'd like to munge the data to be standardized, like this
device: {
id: "f5e30ccd7a3d4678681b580e03d50cc5",
devPath: "/some/path",
label: "abc",
mountPath: "/some/path",
serial: "abc",
uuid: "5406-12F6",
mounted: false,
files: [ ],
ingestId: 123
},
ingest: {
id: 123,
someProp: 123,
anotherProp: 'abc'
}
and then hand that off to something that will know how to add both the device model and the ingest model to the store. I'm just getting confused on all the abstractions in ember data.
Questions:
Which method should I pass that final, standardized JSON to in order to add the records to the store? store.push?
Where is the appropriate place for the initial data munging i.e. getting the event data from the array? Application serializer's extractSingle? pushPayload? Most of the munging will be non-standard across the different routes.
Should per-type serializers be used for each key in the data after I've done the initial munging? i.e. should I had initial "blob" to application serializer, which will then delegate each key to the per-model serializers?
References:
Docs on the store
RESTSerializer

Resources