loopbackio / loopbackio/loopback-next

Where filter with `neq` doesnot work as expected

Open
#6,518 10 comments 3 reactions 1 assignee View on GitHub

@hacksparrow is already working on this.

Since Oct 20, 2020.

bug needs steps to reproduce
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

# Steps to reproduce
1. Create a entity has `id` property as the following
```js
class Sample extends Entity {
@property({
type: 'string',
id: true,
generated: true,
})
id?: string;
// other properties
}
```
2. Make a query to find samples that not equal the `id`. For example
```js
const id = '5f7f32799f3b8031a56e4ca8';
const result = this.sampleRepositoy.find(
{
where: {
id: {
neq: id
}
}
}
)
```
# Current Behavior
`result` still has the entity with id='5f7f32799f3b8031a56e4ca8'

# Expected Behavior
`result` should exclude the id that I used to filter.
I am using mongo with package: "loopback-connector-mongodb: 5.3.0"
Everything will work if I try to install "mongodb" package and replace `neq: id` with `neq: new ObjectId(id)`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.