Comments (9)
There is an issue with this implementation as well. It still doesn't behave as the original mongodb specification is.
For reference here are the tests for the $slice in mongodb jstests code.
from mingo.
Yes. The reason for reopening the issue. Updating with a fix and some test cases.
from mingo.
There is one more issue with $slice. It currently excludes all other fields from the document.
$slice should just affect the property that is being "sliced", and not interfere in any way with the exlusion or inclusion of other fields.
from mingo.
can you provide an example of this behaviour. MongoDB only includes the projected fields in the result.
from mingo.
Sure.
Example document:
{
Text: "MyText",
Array: [1,2,3]
}
Fetching this document with a fields expression of:
{
Array: { $slice: 1 }
}
should return
{
Text: "MyText",
Array: [1],
_id: <....>
}
Notice that the Text and _id field will be included.
Furthermore, you can mix $slice with field exclusion and inclusion without affecting them:
Ex.
{
Array: { $slice: 1 },
Text: 0
}
{
Array: { $slice: 1 }
Text: 1,
_id: 0
}
etc.
Current implementation of mingo returns only the Array field when $slice is used.
from mingo.
Thanks. I am a bit surprised. This looks like a special case in MongoDB. The other projection operator $elemMatch does not behave the same way.
from mingo.
That IS surprising. Didn't know about $elemMatch. I would have expected that it works the same as $slice.
from mingo.
anyway. I have a fix coming up.
from mingo.
issue resolve in release 0.3.3
from mingo.
Related Issues (20)
- Add support for $bottom (aggregation) HOT 1
- Add support for $bottomN (aggregation) HOT 1
- Add support for $top (aggregation) HOT 1
- Add support for $topN (aggregation) HOT 3
- Add support for $minN (aggregation) HOT 1
- Add support for $minN (array) HOT 1
- Add support for $maxN (array) HOT 1
- Add support for $maxN (aggregation) HOT 1
- Add support for $locf (aggregation)
- Add support for $cosh (expression) HOT 1
- Add support for $sinh (expression) HOT 1
- Possible breaking error in 6.1.1 `dateFromParts` HOT 1
- core.addOperators is missing HOT 1
- How does generator function for collection work? HOT 2
- Expressions in arithmetic operators are evaluated in a nested path HOT 2
- Projection not working properly for deep nested objects HOT 1
- $Reduce $Map Returning incorrect results and making other fields return undefined.
- Es6 Module build HOT 1
- [email protected] breaks CommonJS requires of files inside package HOT 20
- Issues with $let since 6.2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mingo.