biota
biota copied to clipboard
Add relations to collections
Summary
Goal is to be able to insure relations between documents in collections.
- 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
- 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
- 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.