bwgjoseph / mongoose-vs-ottoman

feature comparison between mongoose and ottoman
0 stars 1 forks source link

$neq operator #20

Closed bwgjoseph closed 3 years ago

bwgjoseph commented 3 years ago

Hi,

$neq operator seem to work when filtered with number but not for string. See $ne.test.ts

We created this two doc

const doc = {
    callsign: 'Couchbase',
    country: 'United State',
    name: 'Couchbase Airlines',
    hpnumber: 1234,
    operational: true,
    flyingTo: ['Japan', 'Indonesia', 'Korea', 'China', 'Japan'],
    timeOfFlight: Date.now()
};

const doc2 = {
    callsign: 'Mongo',
    country: 'Singapore',
    name: 'Mongo Airlines',
    hpnumber: 5678,
    operational: true,
    flyingTo: ['Thailand', 'UK', 'USA', 'Malaysia', 'Japan', 'Japan']
};

When we run a find

const find = await Airline.find({
            hpnumber : {
                $neq : 1234
            }
        }, { consistency: SearchConsistency.LOCAL});

It returns doc2 only (which seem correct)

1 {
  meta: {
    requestId: 'ef4c265c-2485-4bef-8edd-ab2ddb9da757',
    clientContextId: 'e195b4ed87a16398',
    status: 'success',
    signature: { '*': '*', _type: 'json' },
    profile: undefined,
    metrics: {
      elapsedTime: 24.0137,
      executionTime: 23.9476,
      sortCount: undefined,
      resultCount: 1,
      resultSize: 265,
      mutationCount: undefined,
      errorCount: undefined,
      warningCount: undefined
    }
  },
  rows: [
    _Model {
      _scope: '_default',
      _type: 'Airline',
      callsign: 'Mongo',
      country: 'Singapore',
      flyingTo: [Array],
      hpnumber: 5678,
      id: '7d88f150-748f-4b59-8fd5-5116d147eab4',
      name: 'Mongo Airlines',
      operational: true,
      timeOfFlight: null
    }
  ]
}

But when we run a find

const find2 = await Airline.find({
            country : {
                $neq : 'Singapore'
            }
        }, { consistency: SearchConsistency.LOCAL});

It doesn't return any result back. I'm expecting it to return one result (doc)

2 {
  meta: {
    requestId: 'd3d925ec-b465-42c2-9698-943a41467dee',
    clientContextId: 'facf54a250d09896',
    status: 'success',
    signature: { '*': '*', _type: 'json' },
    profile: undefined,
    metrics: {
      elapsedTime: 3.5393,
      executionTime: 3.4406,
      sortCount: undefined,
      resultCount: 0,
      resultSize: 0,
      mutationCount: undefined,
      errorCount: undefined,
      warningCount: undefined
    }
  },
  rows: []
}

Thanks!

AV25242 commented 3 years ago

Looks like a bug and our team has fixed this, should go out with next release.

bwgjoseph commented 3 years ago

do note that $eq seem to have the same issue as well - See $eq.test.ts

AV25242 commented 3 years ago

Both were taken care by the developer thanks

AV25242 commented 3 years ago

Fixed with issue https://github.com/couchbaselabs/node-ottoman/issues/314 available with release alpha.10

AV25242 commented 3 years ago

@bwgjoseph assign back to you.

bwgjoseph commented 3 years ago

@AV25242 Have verified, and everything looking good now based on current test

Thanks!