0

How can I change primary key of RethinkDB after my rethinkdb feathers service is created?

I tried below code but it won't affect.

app.use('/messages', service({
  id: 'user_id',
  Model: db,
  name: 'messages'
}));

Is there anything I missed?

Harsh Patel
  • 6,334
  • 10
  • 40
  • 73

1 Answers1

0

When using a different primary key the RethinkDB database needs to be initialized with the same primaryKey option. You can either do that manually or use service.init as documented here:

// Initialize the `messages` table with `user_id` as the primary key
app.service('messages').init({
  primaryKey: 'user_id'
}).then(() => {
  // Use service here
});
Daff
  • 43,734
  • 9
  • 106
  • 120