Skip to content

Conversation

@dawidreedsy
Copy link

Sending this query to the query mechanism:

{
      $and: [
        123,
        {y: 1}
      ]
}

should throw the error, however our function castToSnapshotQuery changes it to:

{"$and":[{},{"data.y": 1}]}

Notice that the number 123 was converted to the empty object

Copy link
Contributor

@ericyhwang ericyhwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments from PR review meeting:

  • Small lint fixes, Alec is adding the missing linter to the repo now
  • Remove package-lock.json

index.js Outdated
Comment on lines 144 to 145
if(!isObject(query) || Array.isArray(query)) {
throw new Error('Invalid mongo query format')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after if and semicolon at the end of the thrown error

index.js Outdated
ShareDBMingo.extendMemoryDB = extendMemoryDB;

module.exports = ShareDBMingo;
module.exports = ShareDBMingo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline at end of file

@dawidreedsy dawidreedsy force-pushed the validate-mongo-query branch 3 times, most recently from 164710d to 331586b Compare November 8, 2022 17:16
@dawidreedsy dawidreedsy force-pushed the validate-mongo-query branch 2 times, most recently from 402a49c to 4b146f5 Compare November 8, 2022 17:22
Sending this query to the query mechanism:
```
{
      $and: [
        123,
        {y: 1}
      ]
}
```

should throw the error however our function `castToSnapshotQuery`
changes it to:

```
{"$and":[{},{"data.y": 1}]}
```

Notice that the number `123` was converted to the empty object
@alecgibson alecgibson merged commit f25cafe into master Nov 8, 2022
@alecgibson alecgibson deleted the validate-mongo-query branch November 8, 2022 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants