rethinkdbrethinkdb-javascriptrethinkdb-python

RethinkDB - Automatically generating primary keys that are linear


Is there a way to make rethinkdb generate primary key automatically and to ensure the key is in an increasing order., like say 1 to n

I know when we insert a row into rethinkdb it automatically generates a primary key and returns a variable generated_keys, but I want a primary key which increases in a linear fashion say like starting from 4000 to n or 5000 to n, so on.


Solution

  • I am not aware if it is possible with RethinkDB. However, I know that it is not a feature that would scale well in a cluster of DB servers as it would introduce a bottle neck in the inserts commands.

    It is always possible to do it by hand however, simply by providing an id field to the documents you are inserting in the tables.