0
我只是用迴環開始,我有這樣的「訂單」模式:環回 - 刪除記錄複合主鍵
{
"name": "Orders",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"Client": {
"type": "string",
"id": 1,
"required": true
},
"OrderId": {
"type": "string",
"id": 2,
"required": true
},
"OrderName": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
說,我想使用它的組合鍵(客戶端和的OrderId)刪除訂單。我用這個方法,但它不會刪除的記錄:
var filter = {
where: {
Client: 'AB123',
OrderId: 'ORD1',
OrderName: 'Coffee'
}
};
Orders.findOne({filter: filter}, function(err, order){
if(err){
console.log(err);
}else{
console.log(order); //prints { Client: 'AB123', OrderId: 'ORD1', OrderName: 'Coffee' }
order.destroy();
}
});
我也使用deleteById()方法的嘗試,但它僅接受一個ID /密鑰。任何解決方法在這裏?
在此先感謝。