Can I create compound primary key in RethinkDB ? For example if I have table with next documents strucure {authorsId: '371df80c-2efd-48f9-ac37-3edcdb152fb1', postsId: '905e0c92-adcb-4095-98df-fa08ca71b900'}
how can I create primary key on both together authorsId
and postsId
. Or if I cannot do this how should I use many to many relationship in three tables way. Have I use one field as primary key and second as secondary index ?
Primary keys can only be on one column but you can put postsId
and authorsId
in an array and use that as primary key value.
See here for more information: https://www.rethinkdb.com/api/javascript/table_create/
EDIT
The primary key is still just one field but you can use [postsId, authorsId] as the value for that column and achieve the same. (added back from comment to answer).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With