Insert:

var data = {  
'name' : 'Ajeet',
'age' : 23,
'designation' : "Designer"
};
const insert = await blog.insert(data);
res.send(insert);

response:

{"ok": true,"id": "fac88d73661979cea68db9c3c2000a01","rev": "1-86ca9e7c60eee1d5644e846a699579b5"}

The response of CouchDB for this command contains 3 fields:

  • “ok”: It specifies that the operation is successful.

Get All data:

const q = {
selector: {},
fields: ['name','age','designation']
}
const getAll = await blog.find(q);
res.send(getAll.docs);

Get Single data:

const q = {
selector: {
_id: { '$eq': req.params._id } //where condition
},
fields: ['name','age','designation'] //show field
}
const singleblog = await blog.find(q);
res.send(singleblog.docs[0]);

selector:

selector: {
'$and': [
{ _id: { '$ne': req.body._id } },
{ name: { '$eq': req.body.name } }
]
}

Software Engineer