Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't act as expected !

See original GitHub issue

Hi, I was just testing the library and I faced that in one exact case it doesn’t return expected result. test1

                        let obj1 = {
                            c: { d: "d" }
                        let obj2 = {
                            a: "done",
                            b: 34,
                            c: { d: "d", e:"e" }
                        let result = sift(obj1, [obj2]); 
// result = [obj2]


//collection contains obj2
                       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:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

PascalPflaumcommented, Oct 24, 2017

That the two queries collection.find(c: { d: 'd'}); and collection.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.

  • Query 1 looks for a property c that is equal to { d: "d" }
  • Query 2 looks for a nested property d in c that is equal to d

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.

crcncommented, Apr 11, 2017

If I’m understanding correctly, you’d expect this in sift:

const obj1 = { c: { d: 'd' }};
const obj2 = { a: 'done', c: { d: 'd' }};

const result = sift(obj1, [obj2]); // []

Where result would be an empty array. Currently sift returns obj2 based on the obj1 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.

Mongodb returns obj2 in that case

Sift supports string queries like this:

Read more comments on GitHub >

github_iconTop 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 Hey, as you hopefully can see in the picture i try to pick up a Date from MS Forms and format it,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found