masumsoft/express-cassandra

if_not_exist doesn't return a value

borabaloglu opened this issue · 2 comments

Hi, I don't wanna use duplicated primary keys in my table. I tried to use "if_not_exist: true" option but I have to check a return value so I can throw an error like "this email is already in use".

I looked up the docs but couldn't find any options. Could you please help me about it?

Note: express-cassandra version is 2.3.0, node version is 12.10.0

Wouldn't a normal SELECT email FROM table WHERE primary_key = %.

And using the ORM you can do this:

//If you specifically expect only a single object after find, you may do this
models.instance.Person.findOne({name: 'John'}, function(err, john){
    if(err) throw err;
    //The variable `john` is a model instance containing the person named `John`
    //`john` will be undefined if no person named `John` was found
    console.log('Found ', john.name);
});

closing due to inactivity.