Error: Expected non-object type but got object

I am newly started working with Couchbase. When I insert a record in to the bucket it showing an error like this > Error: Expected non-object type but got object. I am just followed the BikeShop-cb sample in Github. Please any on give me solution to solve.Thanks…

Hey @mahesh,

Can you show us an example of the code that is giving you this error?

Cheers, Brett

@brett19, This my schema

var userMdl = ottoman.model('User', {
    firstName: {type:'string'},
    lastName: {type:'string'},
    created: {type: 'Date', default:function(){return new Date()}},
    email:'string',
    phone: 'string'
},{
	index: {
        findByID: {   
            by: '_id'
        },
    }

})
 userMdl.createAndSave = function (firstName, lastName, created, email, phone,done) {
    this.create({
        firstName: firstName, lastName: lastName, email: email, phone: phone
    }, done);
}
module.exports = userMdl; 

This is my rest call:

app.post('/api/user/create',jsonParser, function(req,res){    
user.createAndSave(req.body.firstName,req.body.lastName,req.body.email,req.body.phone,
                function(err,done){
                    if(err){
                        res.status=400;
                        res.send(err.toString());
                        return;
                    }
                    res.status=201;
                    res.send(done);
                    return;
                });
        });

I am using the postman to sending request.

Hey @mahesh,

I can’t be certain without having your whole app, but I suspect that the values you are receiving from the requests are not strings and dates. You should try checking what exists in your req.body properties before they are sent to UserMdl.create.

Cheers, Brett

@brett19: This is the github link for my source code please check it.github link
I have few doubts regarding updating record in source code routes ->routes.js file having code for update in that I am using replace but it gives an error like user.replace is not a function please let me know if I doing any mistakes in my code.
And also I tried to insert record like below its working fine. Is this process is correct or not ?

        //// ▶▶ user add new user ◀◀ ////
        app.post('/api/user/create',jsonParser, function(req,res){
        console.log("body:"+JSON.stringify(req.body)) 
user.create({firstName:req.body.firstName,lastName:req.body.lastName,email:req.body.email,phone:req.body.phone},
                    function(err,done){       // Here replacing 'create'  in place of createAndSave 
                        if(err){
                            res.status=400;
                            res.send(err.toString());
                            return;
                        }
                        res.status=201;
                        res.send(done);
                        return;
                    });
            });

I am sending the request from postman like:
http://localhost:4000/api/user/create
{
“firstName”:“abc”,
“lastName”:“xyz”,
“email”:"abc@gmail.com",
“phone”:“123xxxxxx”
}