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