Hi I want to create a couchdb database of this format where I can add items in the right type of item(Vegetables or Fruits)
But I want to know how can I add some products in the catalog with the nano utils of couchdb without erasing the list of items already created. The actual method to add products in my catalog is this one: but the problem is that I can add only one item to the catalog. I wanted to make a product.get() but how can I add items to the get result and how can I insert the new list to the database?
function AddProduct(name, price, image, category, id) {
return new Promise((resolve, reject) => {
var catalog = 'catalog'
catalog.insert(
// 1st argument of nano.insert()
{
"catalog": {
category: {
id: {
'name': name,
'price': price,
'image': image,
'category': category
}
}
}
}, 'catalog',
(error, success) => {
if (success) {
resolve(name)
} else {
reject(
new Error(`In adding (${name}). Reason: ${error.reason}.`)
)
}
}
)
})
}```