Doesn't act as expected !
See original GitHub issueHi, I was just testing the library and I faced that in one exact case it doesn’t return expected result. test1
//given
let obj1 = {
c: { d: "d" }
};
let obj2 = {
a: "done",
b: 34,
c: { d: "d", e:"e" }
};
//when
let result = sift(obj1, [obj2]);
// result = [obj2]
test2
//given
//collection contains obj2
//when
let result = collection.find(obj1);
// result = [ ]
Shouldn’t the results of both tests be the same ? Mongodb returns obj2 in that case :
let obj1 = {
"c.d": "d"
};
let result = collection.find(obj1);
// result = [obj2]
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
11/13 the code does not act as expected | Codecademy
I have received the go ahead to move on with the program and the tutorial accepted the following code for calculating the food...
Read more >Net 6 config.GetSection() does not act as expected
I'm trying to get configuration section in .net 6 project, the problem I came across is that GetSection() doesn't act as expected, ...
Read more >43 Synonyms & Antonyms of EXPECTED - Merriam-Webster
Synonyms for EXPECTED: scheduled, anticipated, awaited, slated, due, predicted, envisaged, envisioned; Antonyms of EXPECTED: late, early, belated, overdue, ...
Read more >act as expected | English examples in context - Ludwig
High quality example sentences with “act as expected” in context from reliable sources - Ludwig is the linguistic search engine that helps you...
Read more >formatdatetime not act like expected - Power Platform Community
https://ibb.co/41NzMPq Hey, as you hopefully can see in the picture i try to pick up a Date from MS Forms and format it,...
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
That the two queries
collection.find(c: { d: 'd'});
andcollection.find('c.d': 'd');
have different results is by purpose in MongoDB and one of the tiny details, that makes this query language so powerful.
c
that is equal to{ d: "d" }
d
inc
that is equal tod
I’m in favor of reflecting the mongoDB behaviour as close as possible, something that looks like MongoDB Query Language, but doesn’t behave like MongoDB Query Language is worse than a total different system in my opinion.
If I’m understanding correctly, you’d expect this in
sift
:Where
result
would be an empty array. Currentlysift
returnsobj2
based on theobj1
query – this is intented behavior from when I first added the functionality a few years ago. I’d be open to changing this however to reflect mongodb’s behavior a bit.Sift supports string queries like this: https://github.com/crcn/sift.js/blob/master/test/operations-test.js#L148