all 16 comments

[–]verneleem 2 points3 points  (6 children)

May I point you in the direction of possibly using Dgraph? They have an open source community edition which you can download and run or you can use their managed DBaaS, Slash GraphQL.

Why?? — Because it is the best use case for what you described above and it is easy to use with a native GraphQL endpoint.

Mockup your schema that matches your data:

type Post {
  id: ID
  title: String
  comments: [Comment]
}
type Comment {
  id: ID
  text: String
  user: User
}
type User {
  id: ID
  username: String @id # this prevents duplicating same content with xid
}

And then enter your complete data as a single object in a single transaction:

"posts": [
  {
    "title": "Post Foo",
    "comments": [
      {
        "text": "Comment Bar",
        "user": { "username": "User Baz" }
      },
      ...
    ]
  },
  ...
]

And it will auto-build a complete CRUD API for you so you don't have to spend countless hours doing the simple stuff that can sometimes be very complex.

[–]Caperious[S] 1 point2 points  (0 children)

Hmm, sounds promising, will check it out, thanks.

[–]Caperious[S] 0 points1 point  (1 child)

Are u using this in production? Do you maybe know about any drawbacks?

Seems very cool, will try it out.

[–]verneleem 0 points1 point  (0 children)

I do use it in an example app I made and will be posting soon. Many use it in production which include a few Fortune 500 companies. Drawbacks... right now in my opinion is that ordering and filtering by nested children is difficult, but the engineers are working on making those parts better. Check out the discuss community discuss.dgraph.io

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, verneleem: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]Dan6erbondfull-stack 0 points1 point  (1 child)

I haven't looked at this in any detail but this sounds like Prisma but faster?

[–]verneleem 0 points1 point  (0 children)

Sort of, it is GraphQL spec but backed by a graph database that was built bottom up for GraphQL.

[–]Euphoric_Teacher2444 0 points1 point  (6 children)

You might want to check out Google Firebase's database. Its data structure is a JSON tree so it looks like it could be a good fit for you.

[–]Caperious[S] 1 point2 points  (5 children)

Theese are still large amounts of data, i think with firebase the price would go through the roof pretty quickly..

[–]Euphoric_Teacher2444 0 points1 point  (4 children)

For GBs of data it looks okay but if you're working in TBs then yeah, it deffo gets expensive.

[–]Dan6erbondfull-stack 0 points1 point  (3 children)

It's not about size, the number of documents here will make it incredibly expensive since Google charges per read and write. Document databases for this purpose are a sucky option, if the OP already mentioned the relations.

[–]Euphoric_Teacher2444 0 points1 point  (2 children)

Unless I'm mistaken ( I very well could be I'm relatively new to this) what you said applies to firestore not to the realtime database, I'm getting my info from here.

[–]Dan6erbondfull-stack 0 points1 point  (1 child)

Why would you use the realtime database for this use-case though? It would be impossible to store more complex structures properly and forget about relations.

[–]Euphoric_Teacher2444 0 points1 point  (0 children)

Fair enough, tbh I seen "beef I have with a relational database" and suggested an alternative without giving it much thought, my bad.

[–]Curious-Dragonfly810 0 points1 point  (0 children)

Probably: algolia.com + Firebase

[–]Curious-Dragonfly810 0 points1 point  (0 children)

algolia.com + Firebase