I'm building app using SailsJS, AngularJS and MongoDB, I'm confused how to insert data array into object. This is example my schema
Asset.js
module.exports = {
schema : false,
attributes: {
product : { model : 'Product' },
store : { model : 'Store' },
key : { type : 'object' }
}
};
This is my view form
<tbody ng-repeat="attr in product.category.templateAttribute" ng-show="{{product.category.name == 'custom'}}">
<tr>
<td>
<input class="form-control input-small" value="{{attr.attribute}}" />
</td>
<td>
<input class="form-control input-small" placeholder="name" ng-model="product.attributes[attr.attribute].name" />
</td>
<td>
<input class="form-control input-small" placeholder="add price" ng-model="product.attributes[attr.attribute].additionalPrice" />
</td>
</tr>
<tr>
<td colspan="3">
<file-uploader class="form-control input-small"
max-size="25000"
result-model="product.attributes[attr.attribute].file">
</file-uploader>
</td>
</tr>
</tbody>
This is the my query
ProductCustomAsset.create({
product : product.id,
store : product.store,
key : product.attributes
})
.then(function(){
next();
})
.catch(function(error){
next(error);
});
What is the problem in my query,no error but value in key only array no object.
I want result to be this
{
"_id" : 5,
"product" : 3,
"store" : 2
"key": [
{
"attribute": "xxxxxxx",
"name": "book",
"additionaPrice": "xxxx",
"file": "xxxx" ,
}
]
}