i have to save a json in array but i can't in
controllers/api.js
exports.install = function() {
F.cors('/api/db/*',['post'],false)
F.route('/api/db/',saveNoSql,['post']);
};
function saveNoSql(){
console.log('dentro saveNoSql');
var self = this;
var body = self.req.body;
var users = NOSQL('db');
users.find().make(function(builder){
builder.and()
builder.where('name','Report');
builder.where('entries['+0+'].name','Report');
builder.callback(function(err,model){
})
})
}
databases/db.nosql
{"name":"Report","user":"rep","password":"admin","odata":"false","entries":[{"name":"Report","appointment":[{"idOrder":"1","order":"order 1","supplier":"fornitore 1","hours":"numero ore","actions":"icone azioni"}]},{"name":"Admin","appointment":[]}]}
{"name":"Admin","user":"adm","password":"admin","odata":"true","entries":[]}
{"name":"Mike","user":"mike","password":"admin","odata":"true","entries":[]}
Here you see that i have to save a req.body in name->Report/entries->Report/appointment and i guess to do that with find() and insert() , right?
This is solution, but not much effective:
I recommend to update all documents by adding new filter fields for much simpler filtering. Documentation: https://docs.totaljs.com/latest/en.html#api~DatabaseBuilder~builder.filter