-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I'm having trouble understanding why index and validation is not working on my Model defined programatically. Below is the setup of a simple shopping cart Model, for which I need to use a custom id which is not at the root level of the model.
var defaultSettings = {idInjection:false, strict:true};
var CartEntityModel = {
'products':{type:[Product], required:false}, // Product is defined elsewhere
'cartId':{type:String, required:true, index:true, generated:true}
}
var CartEntity = ds.define('cartEntity', CartEntityModel, defaultSettings);
var cartProperties = {
'_entity': {type:CartEntity, required:true}
}
app.model('cart', {
properties: cartProperties,
options: defaultSettings,
dataSource: 'mongodb'
});
This generates an id field at the root of the 'cart' and only validates that the _entity field is not empty. No other validation at lower levels takes place and the index property seems to be entirely ignored. What am I doing wrong here?
The structure is more complex than absolutely necessary because I need to match an existing data structure, which always has '_entity' at the root and the id's at deeper levels.
thijsvanbuuren and joshrickertrdzak