0
如何在使用羽毛/ Vue堆棧的Mongoose中對查詢進行驗證?這是我正在經歷的。傳遞給feathers-mongoose服務的任何查詢條件必須在Vue模型中傳遞,以便運行查詢,該查詢過濾掉沒有名稱屬性或根本沒有該字段的返回項目。這是它不起作用時的樣子。注意'真實'的結果。 使用Feathersjs和Vue進行貓鼬驗證
var vm = new Vue({
el: '#app',
data() {
return {
places:[]
}
},
ready() {
// Find all places
placeService.find({
query: {
** name: { $exists: true } **
}
}).then(page => {
this.places = page.data
})
}
})
如果您在您服務「選項」查詢最終將顯示與「真」表示{{i.name}} index.html中的項目添加此。該服務設置:
module.exports = function() {
const app = this;
const options = {
Model: place,
paginate: {
default: 15,
max: 30
},
// query: {
// name: { $exists: true },
// city: { $exists: true }
// }
};
// Initialize our service with any options it requires
app.use('/places', service(options));
另要注意,如果您嘗試使用內置的驗證從視圖模型的羽毛
$select: { name: { $exists: true }}
,如下圖所示,或通過添加
{$exists:true}
到貓鼬模型,你會得到相同的結果,如果你在羽毛 - 貓鼬選項中運行它。
ready() {
// Find all places
placeService.find({
query: {
$select: { name: { $exists: true }}
}
}).then(page => {
this.places = page.data
})
}
謝謝。
你'console.log'從查詢返回的頁面數據?它看起來像預期的一樣嗎?它看起來像你有錯誤的數據和約束固定輸出。 – Daff