orientdb like query with node js

I am working on an application with orientdb, NodeJS, Express and AngularJS. I am new to these technologies. I am writing a select query at the NodeJs end that returns data from OrientDB which is then displayed in frontend using AngularJS. But I wish to return only a part of the data when I enter value in a search key text box on homepage. I am following this link for OrientDb queries and trying this:

var key = "trade"
db.query('select from table where value like "%:searchkey%"', {
params: {
searchkey : key
        }   
}).then(function (results) {
        stringresult = results;
        res.json({"value":stringresult});

});

But the above code doesn't return any result. I tried playing around with the query, removing quotes from the searchkey and so on but that doesn't help either. This query works perfectly fine in the OriendDb console like this:

select from table where value like "%trade%"

The error might be because of the single or double quotes that I have used or the params but I am not sure.I have looked everywhere for a solution to this problem but could not find one.

Answers


Yes, I believe the problem is that you're not putting the wildcards in properly. They need to be added to the key, and not the query.

var key = "trade"
db.query('select from table where value like :searchkey', {
params: {
searchkey : "%" + key + "%"
        }   
}).then(function (results) {
        stringresult = results;
        res.json({"value":stringresult});

});

Need Your Help

Java : Compare, mark and interpret HTML texts in Java

java html string string-comparison

I am working on a Java project, where there is an HTML editor and the user can enter text in a html-editor(ckeditor) and the actual HTML text is saved in the database.