Talib Allauddin
Talib Allauddin

Reputation: 109

Store array of ObjectId's in sailsjs using waterline ORM

I'm trying to store array of Object Id's of another model.

Sub Service

    skills: {
        collection: 'subservice',
        via: 'contractors'
    },

Contractor Model

   contractors : { 
       collection: 'contractor', 
       via: 'skills' 
   },

and this solution didn't worked... How to store array of ObjectID's in Mongo with Sails?

Upvotes: 1

Views: 811

Answers (1)

SkyQ
SkyQ

Reputation: 380

In this two models you are using via so you must specify which model is dominant:

Sub Service

skills: {
    collection: 'subservice',
    via: 'contractors',
    domiant: true
},

Contractor Model

contractors : { 
   collection: 'contractor', 
   via: 'skills' 
},

More info: http://sailsjs.org/documentation/concepts/models-and-orm/associations/dominance

Upvotes: 2

Related Questions