Sails: Add arrays as a model attribute type

Created on 26 Jun 2013  路  3Comments  路  Source: balderdashy/sails

As far as I can tell it is not possible to use array (or boolean?) types in models, e.g.

var Person = {
  name: 'STRING',
  age: 'INTEGER',
  phones: [ { mobile: 'BOOLEAN', number: 'STRING' } ]
};

Is this lack of attribute types a design choice or are there plans for added these types?

Most helpful comment

I can't find documentation anywhere on how to use the attribute type 'array'
I'd like to merely create the following:

location: [Number, Number]

Would be glad if anyone could point me to the docs for this.
Thanks

All 3 comments

we added the array type a few days ago: https://github.com/balderdashy/waterline/issues/30#issuecomment-19730397

We have to manage adding types with how they will be implemented across various adapters. If it's possible to to do I will add a type but if it takes a lot of hacking on all the adapters it's prob. not worth adding. You can see all the supported types here: https://github.com/balderdashy/waterline/blob/master/lib/waterline/utils/types.js

That is perfect! Thanks for taking the time to reply.

At some point it would probably make sense to include functions for querying and manipulating model array types directly in waterline. E.g. pushing a new value to array, popping values from array or query for value in array (like MongoDB's array operators)

I can't find documentation anywhere on how to use the attribute type 'array'
I'd like to merely create the following:

location: [Number, Number]

Would be glad if anyone could point me to the docs for this.
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnGrisham picture JohnGrisham  路  4Comments

randallmeeker picture randallmeeker  路  4Comments

Noitidart picture Noitidart  路  4Comments

danil-z picture danil-z  路  3Comments

alxndrsn picture alxndrsn  路  4Comments