0
我想爲了使用sequelize製作簡單的查詢,善良的查詢:凡與搜索到的對象的「內部關係」
SELECT * FROM `Products`
WHERE `Product`.`oldPrice` > `Product`.`newPrice`
目前,我做那種醜陋的原始查詢,如:
database.Product.find({ where: '`Product`.`oldPrice` > `Product`.`newPrice`' })
這是不是真的不好的做法或東西,但我不知道我是否沒有錯過一個段落這將我介紹給一個更清潔的形式,例如像蒙戈函數表達式(參見:http://mongoosejs.com/docs/api.html#query_Query-%24where)的文件之中。
database.Product.find({ where: function() {
return (this.oldPrice > this.newPrice);
});
是否有這種類型的快捷方式,或者我將不得不在這種情況下繼續編寫SQL?
在此先感謝。