Skip to content

Instantly share code, notes, and snippets.

@drexel-ue
Last active June 24, 2019 12:09
Show Gist options
  • Select an option

  • Save drexel-ue/b72888f4eebd006da523d46dff2ebd9a to your computer and use it in GitHub Desktop.

Select an option

Save drexel-ue/b72888f4eebd006da523d46dff2ebd9a to your computer and use it in GitHub Desktop.
QUERY:
final alertQuery = Query<User>(context)
..join(set: (User user) => user.likes).returningProperties(
(Like like) => [like.createdAt, like.liker.displayName])
..join(set: (User user) => user.shares).returningProperties(
(Share share) => [share.createdAt, share.sharer.displayName]);
RESPONSE:
[{id: 56, createdAt: 2019-06-23T00:51:38.411783Z, username: [email protected], displayName: novachrono, realName: Ryan Coswell, profilePicUrl: null, bio: null, entries: null, followers: null, following: null, challengesCreated: null, coinsAvail: null,
likes: [
{id: 7, createdAt: 2019-06-23T03:50:51.421967Z, liker: {id: 57}}, << only contains id
{id: 8, createdAt: 2019-06-23T04:04:53.088541Z, liker: {id: 57}},
{id: 9, createdAt: 2019-06-23T04:04:56.632456Z, liker: {id: 57}},
{id: 10, createdAt: 2019-06-23T04:06:00.188748Z, liker: {id: 57}},
{id: 11, createdAt: 2019-06-23T04:06:01.512768Z, liker: {id: 57}},
{id: 12, createdAt: 2019-06-23T04:06:14.932521Z, liker: {id: 57}},
{id: 13, createdAt: 2019-06-23T04:06:14.990030Z, liker: {id: 57}},
{id: 14, createdAt: 2019-06-23T04:06:15.133661Z, liker: {id: 57}},
{id: 15, createdAt: 2019-06-23T04:06:22.468643Z, liker: {id: 57}}
],
shares: []}] << should be empty at the moment. no shares in database
EXAMPLE FROM DOCS:
var q = Query<User>(context)
..join(set: (u) => u.tasks);
var users = await q.fetch();
users.first.asMap() == {
"id": 1,
"name": "Bob",
"tasks": [
{"id": 1, "contents": "Take out trash", "user" : {"id": 1}},
...
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment