How do I use validation with queries in Mongoose with Feathers/Vue stack? This is what I am experiencing. Any query terms passed to the feathers-mongoose service has to be passed in the Vue model for it to run the query which filters out returned items that dont have a name property or dont have the field at all. This is what it looks like when it doesnt work. Notice the 'true' result.
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
})
}
})
If you add this in “options” on your service the query will end up showing the item with 'true' showing in {{ i.name }} in index.html. This the service setting:
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));
Another note, if you try to use the feathers built in validation from the view model with
$select: { name: { $exists: true }}
as seen below, or by adding
{$exists:true}
to the mongoose model, you will get the same result as if you ran it in feathers-mongoose options.
ready () {
// Find all places
placeService.find({
query: {
$select: { name: { $exists: true }}
}
}).then(page => {
this.places = page.data
})
}
Thank you.