biota icon indicating copy to clipboard operation
biota copied to clipboard

Add relations to collections

Open gahabeen opened this issue 4 years ago • 0 comments

Summary

Goal is to be able to insure relations between documents in collections.

  1. one to one
  • adds a unique constraint
  • a field on one of the two collection refers to the other one
  • scaffolding of indexes to query against it
  1. one to many (also many to one)
  • a field on one of the two collection refers to the other one
  • scaffolding of indexes to query against it
  1. many to many
  • creation of a new collection name biota.relation.<relation-name>
  • scaffolding of indexes to query against it

Basic example

How the api would look like:

// one to one
db.relation('user_address').one("address").connects.one("user", "contact.address")
// where 'address' refers to the Collection("addresses")
// where 'user' refers to the Collection("users") and "contact.address" is the field to be looked up

// many to one
db.relation('question_answers').many("answers", "question").connects.one("question")
// where 'answers' refers to the Collection("answers") and "question" is the field to be looked up
// where 'question' refers to the Collection("questions")

// many to many
db.relation('participations').many("polls", "users").connects.many("users", "polls")
// where 'polls' refers to the Collection("polls") and "users" the users ref list (added in the relations obj)
// where 'users' refers to the Collection("users") and "polls" the polls ref list (added in the relations obj)

Motivation

Simplify the relations management between collections.

gahabeen avatar Apr 15 '20 08:04 gahabeen