User.find({ _id: { \'!\': user.id } }, function foundFriends (err, friends) {
if(err) return next(err);
res.view({
friends: friends
});
}
Hi you can try this for find, update, or destroy by id with sails-mongo via select
:
//Schema
module.exports = {
autoPK : false,
attributes : {
id : {
type: 'string',
primaryKey: true
},
name : {
type : 'string'
},
email : {
type : 'string'
}
}
}
// Find
User.find({
select : {id : user.id}
}).exec((err,record)=> {
if(err) return console.log(err,"err");
console.log(record,"record");
})
// Update
User.update({
select : {id : user.id}
},{
name : "Foo"
}).exec((err,record)=> {
if(err) return console.log(err,"err");
console.log(record,"record");
})
// Destroy
User.destroy({
select : {id : user.id}
}).exec((err,record)=> {
if(err) return console.log(err,"err");
console.log(record,"record");
})
Hope this can help to you.