Ottoman V2. Find document using value from array

{
“active”: true,
“amount”:50
“markup”:“Hotel”,
“agent”: [
“dfac805f-ba2e-4672-9b88-8bd7cc11d3d6”,
“65f1c0fb-09fa-4dfa-bf32-f1a1379bd5c3”
]
}

here I want to find my agent using $in, contains, and $all but not get any record.
Is there any other way to find records?

var result = await Markup.find({ agent: { ‘$in’: [agents.id.toString()] } });

got result QueryOperatorNotFoundException [Error]: Operator not found: $in

OR
Need Result : using agent key
dfac805f-ba2e-4672-9b88-8bd7cc11d3d6
{
“active”: true,
“amount”:50
“markup”:“Hotel”
}

Hi @Nikhil_Bharambe the syntax is incorrect, look at the example below this works

const { model, Schema, Ottoman } = require('ottoman')
const ottoman = new Ottoman({ collectionName: '_default' })

// ottoman connect does not does not return a connection object anymore
ottoman.connect({
  connectionString: 'couchbase://localhost',
  bucketName: 'default',
  username: 'Administrator',
  password: 'password'
})

const serviceSchema = new Schema({
    service: String,
    serviceId: String,
    serviceCode: String
})

var agentSchema = new Schema({
    agentId: { type: String },
    name: { type: String },
    mobile: { type: String },
    Services: { type:String, ref: 'Service' },
    atype: { type: String },
    })
  
  const Service = model('Service', serviceSchema);
  const Agent = model('Agent', agentSchema);

  const filter = {
    $in: { search_expr: 'agentId', target_expr: ['124554','123456'] }
  }
   const runAsync = async () => {
    try {
      const result = await Agent.find( filter);
      console.log(result)
    } catch (error) {
      throw error
    }
  }
  

  runAsync()
1 Like

thank you so much, @AV25242