These are chat archives for Automattic/mongoose

21st
Oct 2018
CandleCoder
@CandleCoder
Oct 21 2018 02:03
Hi
Kev
@lineus
Oct 21 2018 14:12

@chaiwa-berian

How can I create a custom validator that checks that a given array field on the schema should not be empty?

in your code sample above, you've defined the validator on the array element instead of the array itself.
Here's an example gist of defining it on the array instead

Hi @CandleCoder !
Berian
@chaiwa-berian
Oct 21 2018 16:47
@lineus Thank you! That fixed it!
Berian
@chaiwa-berian
Oct 21 2018 20:53
Hello here! Does someone know how I can create the endpoint to accept valid mongodb query operations or filters? So I would like the user of my api to be able to send something like { _id: { $in: [<value1>, <value2>, ... <valueN> ] } } as a filter or any other valid mongodb query and projection operators!
So the uri for the endpoint would look like: http://localhost:3000/api/silc_groups?_id:$in:[abcd1,ababa2,ababab3] but I am getting something that needs much more processing on the server. Any tips?