0
Loopback.js에서 단일 API 요청을 사용하여 여러 모델 인스턴스를 한 번에 PATCH 또는 DELETE 할 수 있는지 궁금합니다. I 업데이트 할 모델 인스턴스의 배열을 포함하는 호출을 통해 수행 할 수 있었지만 분명히 작동하지 않습니다.Loopback.js - 하나의 호출로 여러 모델 인스턴스를 업데이트하거나 삭제할 수 있습니까?
Loopback.js에서 단일 API 요청을 사용하여 여러 모델 인스턴스를 한 번에 PATCH 또는 DELETE 할 수 있는지 궁금합니다. I 업데이트 할 모델 인스턴스의 배열을 포함하는 호출을 통해 수행 할 수 있었지만 분명히 작동하지 않습니다.Loopback.js - 하나의 호출로 여러 모델 인스턴스를 업데이트하거나 삭제할 수 있습니까?
이 persistedmodel 방법을 사용
1 UpdateAll
PersistedModel.updateAll([where], data, callback)
More info, check the official documentation
PersistedModel.updateAll({
field1: value1,
field2: value2,
},
data,
function (err, info) {
if (err) { console.log(err); }
console.log(info, info.count); // shows number of udaptes
})
2 DestroyAll
을More info, check the official documentation
PersistedModel.destoryAll({
field1: value1,
field2: value2,
},
data,
function (err, info) {
if (err) { console.log(err); }
console.log(info, info.count); // shows number of items deleted
})