Search code examples
node.jsexpresscassandraexpress-cassandra

Express-Cassandra multiple value search from SET data type in same query on a single column


In Express Cassandra, i have a method to get data from table using "contain" keyword where data type is SET now i get data from table while use single value in contain, my custom query given below

var query = {
  participants: { $contains: uuid},
  group: { $eq: 'no' },
  single: { $eq: 'yes' }
};

models.instance.Conversation.find(query,{ raw: true, allow_filtering: true }, function(err, conversation) {
    if(err) throw err;
    else console.log(conversation);     
});

Now, problem is, i need to check it by multiple value. but i don't know how it place in query. google for it but just waste my time. any one can help me. Thnaks


Solution

  • we can get the raw query interface from cassandra nodejs-driver using the execute_query method.

    var query = "SELECT * FROM conversation WHERE participants CONTAINS '1stvalue' AND participants CONTAINS '2ndvalue' ALLOW FILTERING;";
    models.instance.Conversation.execute_query(query, {}, function(err, Conversations){
        //Conversation is an array of plain objects
    });