how to use the attribute type like 'array' and 'json' in sails

Viewed 7540

Sails have support very convenient model througth Waterline, and I have used the 'array' attribute type in the way storing many string, but now I want to store more complex object, Although I can store the raw data in mongo by 'array' type, I don't know if it is safe and I want define the object type in the array, like mongoose's style. for example, I need a model "Products" and I want define it as a 'array' but the object stored in the array only model "Book", what I can do like this, but I don't think it works.

module.exports = {
  products : {
    type : 'array',
    Book : {
      name : 'string',
      price : 'integer'
    }
  }
}

So, any suggestion about use of the 'array' and 'json' is very appreciated, thanks so much!

1 Answers
Related