v2.Ottoman "Find" not populate data from couchbase

need result as per the document below
// Populate using Model
const stories = await Story.find({ title: ‘Casino Royale’ }, {populate: ‘author’})
const story = stories[0];
console.log(‘The author is %s’, story.author.name);
// prints “The author is Ian Fleming”

my example is :

const Services= new Schema({
service: String,
serviceId: String,
serviceCode: String,
});
module.exports =connection.model(“Services”, Services);

var schema = new Schema({
agentId: { type: String },
name: { type: String },
mobile: { type: String },
Services: [{ type: Services, ref: “Services” }],
atype: { type: String },
});

schema.index.findByAgentID = {
by: ‘agentId’,
type: ‘refdoc’,
};

schema.index.findByAType = {
by: ‘atype’,
type: ‘refdoc’,
};

module.exports =connection.model(“Agent”, schema );

but not populate services

Que. 1: Not populate using find as per ottoman document

const result = await Agent.find({ atype: “agent” }, { populate: ‘Services’ });
got error Unable to populate field “Services”, it is not available on select clause

Que. 2: if I use findByAType then working fine but at the insert time got error document already exists.

because I add atype=“agent” for all data,

please tell me how to get all the agent data lists of an agent with populated data?

expected result :
[{
“agentId”:“124554”,
“name”: “Suresh”,
“mobile”: “8898989817”,
“atype”:“agent”,
“Services”: [
{
“serviceId”: “16546555”,
“service”: “HOTEL”,
“serviceCode”: “HT”,
},
{
“serviceId”: “16546556”,
“service”: “Airline”,
“serviceCode”: “AL”
}
]
},{
“agentId”:“123456”,
“name”: “Amit”,
“mobile”: “8898989818”,
“atype”:“agent”,
“Services”: [
{
“serviceId”: “16546555”,
“service”: “HOTEL”,
“serviceCode”: “HT”,
},
{
“serviceId”: “16546556”,
“service”: “Airline”,
“serviceCode”: “AL”
}
],
}]

Hello @Nikhil_Bharambe

here is the my code and it 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 },
    })
    
    agentSchema.index.findByAgentID = {
    by: 'agentId',
    type: 'refdoc'
    }
        
    agentSchema.index.findByAType = {
    by: 'atype',
    type: 'refdoc'
    }

  const Service = model('Service', serviceSchema);
  const Agent = model('Agent', agentSchema);

  
   const runAsync = async () => {
    try {

      const result = await Agent.find({ atype: 'agent' }, { populate: 'Services' });
      console.log(result)
    } catch (error) {
      throw error
    }
  }
  

  runAsync()