moleculer-db icon indicating copy to clipboard operation
moleculer-db copied to clipboard

Populate with query

Open NsSumse opened this issue 7 years ago • 2 comments

Is there a plan to add (sort/query) support for populating?

NsSumse avatar Apr 15 '18 21:04 NsSumse

If you need more complex populating, use this form:

{
    settings: {
        populates: {
            termCount(ids, books, rule, ctx) {
                return this.Promise.all(books.map(async book => book.termCount = await ctx.call("terms.count", { query: { book: book._id } })));
            }
        }
    }
}

icebob avatar Apr 16 '18 05:04 icebob

I'd like to populate with the parameters in my call.

broker.call('v1.User.find', {
    query: {},
    populate: {
        books: {
            query: {
                price: 50
            },
            populate: {
                //sth else
            },
            page: 2,
            pageSize: 10
        }
    }
});

NsSumse avatar Apr 17 '18 06:04 NsSumse