loopback-next
                                
                                
                                
                                    loopback-next copied to clipboard
                            
                            
                            
                        Where filter with `neq` doesnot work as expected
Steps to reproduce
- Create a entity has 
idproperty as the following 
class Sample extends Entity {
@property({
    type: 'string',
    id: true,
    generated: true,
  })
  id?: string;
  // other properties
}
- Make a query to find samples that not equal the 
id. For example 
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)
related to #1875, and #3720
Hi @mdbetancourt Seem issue https://github.com/strongloop/loopback-next/issues/3720 is still opening, so its mean that I should continue waiting for it?
Because I tried to add mongodb: { dataType: 'ObjectID' } into @property decorator or set strictObjectIDCoercion to true in @model but they didn't work as well.
@hacksparrow, could you please take a look, since you're working on the ObjectID task? Thanks.
@trieuduong1602 ObjectId configuration can be tricky, please share a minimal app reproducing the issue, I will configure it for you.
@hacksparrow sorry for late reply, I just invited to my project "reproduce-loopback-4-bugs" (I marked this project as private as well, so please accept it)
==== Project preparation: after you cloned my project, please do the following steps:
- Open terminal in the project root. Inside terminal, calling following command 1.1 git checkout issues/6518-use-neq-statement-does-not-work 1.2 source build.local.sh 1.3 npm run db:deploy 1.4 npm run migrate -- --rebuild 1.5 npm start
 - open loopback swagger by: http://localhost:3002/explorer/
 - use api: "/categories" to get all categories that I seeded before. (there are 2 categories only)
 - Pick one 
idin the categories list. - use api: "/categories/{id}/neq" with this id ==== Expection: The categories list returned by api '/categories/{id}/neq' should exclude the id that you chose (i.e, there should be return 1 category in the list only, instead of 2)
 
I have same problem when calling findOne. The problem persists even if installed "mongodb" package and replace neq: id with neq: new ObjectId(id).
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.
Has there been any progress on this subject? The issue persists with the latest version of loopback.
If anyone seeks for a workaround, this should do the trick:
where: {
  // @ts-ignore
  "_id" : {
      neq: new ObjectId('5f7f32799f3b8031a56e4ca8')
  }
}