0

I'm starting a project on Rails using an already existing MongoDB database which is already in production and is being used by another node.js app, which uses mongoose as it's ODM.

I have two types of objects stored in a collection called asset. Mongoose uses the key __t to keep track of the object's type and mongoid uses _type.

Is there a way to force mongoid to discriminate document type using the __t key instead of _type?

Juan Fuentes
  • 1,743
  • 2
  • 20
  • 33
  • It appears to be hardcoded in Mongoid as `_type`, so I think not. – Ryan Bigg Jul 07 '17 at 01:41
  • 1
    Would this not simply follow the Active Record pattern as shown in [How to customize Rails 3 STI column name](https://stackoverflow.com/a/9454707/2313887)? Not sure since I don't have something currently available to test, but it would seem logical. If not then you can always consider changing the key used by mongoose whilst both are running. This is `{ discriminatorKey: '_type' }` for the schema options on each model. – Neil Lunn Jul 07 '17 at 03:27

0 Answers0