Slice in populate throws error
See original GitHub issueI have two collection, a cart, and product Cart has an array of items with references to products The product has a prices array.
I want to do a query where I get the cart, and populate the products, but with the prices array sliced. I use the following query:
Cart.findById( id )
.populate({
path:'items.products',
options: {
slice: {
'prices': 1,
}
}
})
But it throws this error:
Error: slice() must be used after where() when called with these arguments
Issue Analytics
- State:
- Created 10 years ago
- Comments:9
Top Results From Across the Web
javascript - Why slice() is showing error but code run perfectly?
P.S.. This error will be shown first 4 times when i have total 6 values inside items. items is having object array. when...
Read more >Mongoose v6.8.2: API docs
If bufferCommands is true, Mongoose will throw an error after bufferTimeoutMS if the operation is still buffered. [options.dbName] «String» The name of the ......
Read more >Understanding Arrays and Slices in Go - DigitalOcean
This article will cover the array and slice data structures in the Go Programming language, which will provide you with the necessary ...
Read more >The Basics of Indexing and Slicing Python Lists | by Joseph H
“Slicing” means getting a subset of elements from an iterable based on ... the slicer stops before populating any value into the slice....
Read more >Salesforce CPQ error "Cannot read property 'slice' of null ...
When checking Renewal Quoted in a contract, an error appears: Cannot read property 'slice' of null. This error occurs when the Renewal Opportunity...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have a similar task: We have a collection of messages. Messages can have replies which are messages too. Only last reply (if any) should be returned with each message. I’ve tried to make a population like this:
It works, but I’ve got another problem. I also need a total number of replies which is the
length
ofreplies
array. I have a virtual property to get that. The thing is that after populationreplies.length
becomes1
.Great, thanks!