bookshelf.js: 如何在查询中使用 updatePivot
bookshelf.js: how to use updatePivot with a query
我正在使用:
.updatePivot({sort_order:2}, [some query goes here])
如何设置查询格式以便仅更新联接 table 中的查询行?我试过:
.updatePivot({sort_order:2}, { where: {tagId: 117} })
但这仍然将 table 中所有行的 sort_order 设置为 2,而不仅仅是 tagId=117 的行。
updatePivot 的文档说选项参数是选项的散列。所以你需要将它指定为
.updatePivot({sort_order:2}, { query: { where: {tagId: 117} } })
或者我相信你可以做类似的事情
.forge({tagId: 117}).related('b2m relationship').updatePivot({sort_order: 2})
我正在使用:
.updatePivot({sort_order:2}, [some query goes here])
如何设置查询格式以便仅更新联接 table 中的查询行?我试过:
.updatePivot({sort_order:2}, { where: {tagId: 117} })
但这仍然将 table 中所有行的 sort_order 设置为 2,而不仅仅是 tagId=117 的行。
updatePivot 的文档说选项参数是选项的散列。所以你需要将它指定为
.updatePivot({sort_order:2}, { query: { where: {tagId: 117} } })
或者我相信你可以做类似的事情
.forge({tagId: 117}).related('b2m relationship').updatePivot({sort_order: 2})