sails-hook-nested
v0.3.0
Published
Nested attributes for sails models.
Downloads
5
Readme
sails-hook-nested
Nested attributes for sails models.
TODO
- Test deep nested attributes
- Change from forgJs syntax to regular sails attribute types
Getting started
Add a nested object/array definitions to your model.
These attributes must conform to the forgJs syntax, for now!
module.exports = {
attributes: {
// nested attributes definitions
arrayOfObjects: {
type: 'nested_array',
of: {
wa: {type: 'int', optional: true},
res: {type: 'string'},
entry: {type: 'int'},
correct: 'boolean',
deep: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean',
deepArray: {
type: 'nested_array',
of: {
wa: {type: 'int', optional: true},
res: {type: 'string'},
entry: {type: 'int'},
correct: 'boolean',
deeper: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean',
evenDeeper: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean'
}
}
}
}
},
required: true
}
}
}
},
required: true
},
nestedAttributes: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean',
deep: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean',
deeper: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean',
evenDeeper: {
type: 'nested_object',
of: {
ten: {type: 'int', min: 0, max: 10, optional: true},
shoo: {type: 'string', minLength: 6, maxLength: 22},
maybe: 'boolean'
}
}
}
}
}
}
}
},
// regular sails attributes
num: {
type: 'number'
},
word: {
type: 'string'
}
}
};