-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple where conditions #17
Comments
Definitely.checkout out http://dev.yathit.com/ydn-db/nosql-query.html Calling |
Thanks. i didn't dig the entire code. if the multiple where is possible by passing an array it would be cool? (may be this is a bad idea) var q = db.from('people').where([['age', '=', 25],['state','=','ny']]); |
Can you reasonable argue why it is better than |
+1 |
Which file are you using? You need On Fri, Aug 22, 2014 at 7:40 PM, Erez Pilosof [email protected]
|
I also have problem with multiple conditions. I am using ydn.db-isw-sql-e-cur-qry-de and the query I want to make is simply: where condition1 = '1' Iterate over all objects... |
Index base query is possible. But That kind of complex query is work in progress. Checkout in /query folder. |
Hello yathit.. Now I am trying to fetch all entries by two conditions. In Sql it would look like: How can I do this in ydn db? I did it like this: |
@OopDeveloper89 check out compound index or key joining as described in http://dev.yathit.com/ydn-db/nosql-query.html |
I used as workaround sql query. Is this a correct way? |
Hello there, thank you for this library! In my case I'm struggling with multiple where conditions with OR operator. Is there any way to apply two where conditions with an OR operator without having to do two queries? I'm trying to do the following query: WHERE (timestart >= X OR timeend >= X) AND timestart <= Y If I chain .where functions they always use AND operator. Thanks! |
Multiple equal-AND over multiple OR query is possible. Multiple keyrange-AND is not possible. You will have to use on memory filter for the rest of range query. |
Hello @yathit, I also want to combine multiple Do I need to add an index for all my field names which are used in the I always get the error: |
Yes, all field in where clause mutual be indexed. It was old url. All pages are in documation section on the site.
|
Thanks for your fast reply. I created indexes for Do you see what I am doing wrong? var schema = {
stores: [
{
name: 'users',
autoIncrement: true,
indexes: [
{
name: 'name',
keyPath: 'name'
},
{
name: 'age',
keyPath: 'age'
},
{
name: 'name, age',
keyPath: ['name', 'age']
}
]
}
]
};
var db = new ydn.db.Storage('my-db', schema, {mechanisms: ['indexeddb']});
db.clear();
var values = [
{"name": "Lara", "age": 45, "registered": "2015-12-21T10:14:59.661Z"}
, {"name": "Sarah", "age": 25, "registered": "2016-01-12T09:00:32.736Z"}
, {"name": "Benny", "age": 28, "registered": "2015-12-21T09:55:17.201Z"}
, {"name": "John", "age": 39, "registered": "2015-12-18T11:14:50.426Z"}
, {"name": "Benny", "age": 30, "registered": "2014-12-18T11:14:50.426Z"}
];
for (var i = 0; i < values.length; i++) {
db.put('users', values[i]);
}
var query =
db
.from('users')
.where('name', '=', 'Benny')
.where('age', '<', 30)
.list()
.done(function (records) {
records.forEach(function (record) {
console.log('Result', record);
});
}); |
Good news! I solved the |
That function is not finished yet. The multiple where clause should generate query as follow:
|
Thanks for your answer. I changed the following: .where('name', '=', 'Benny')
.where('age', '<', 30) -> .where('name, age', '<', ['Benny', 30]) These changes cause now this error: But I have there is an index {
name: 'name, age',
keyPath: ['name', 'age']
} Also... Shouldn't there be two operators for the multiple where clause? Because I need |
All look good. Please post to jsbin. |
Thanks for helping me! I made a Fiddle: https://jsfiddle.net/bennyn/ynchm1tw/ Your library is added under External Resources. |
Definitely a bug. currently use https://jsfiddle.net/ynchm1tw/2/ |
Thanks for helping out! This works: var iterator =
ydn.db.IndexValueIterator
.where('users', 'name, age', '>', ['Benny'], '<', ['Benny', 30]);
var query =
db
.values(iterator)
.done(function (records) {
records.forEach(function (record) {
console.log('Result', record);
});
}); |
As a note, none of my application use query api and the bug fix will be slow. |
Is it possible to make multiple where conditions?
var q = db.from('people').where('age', '=', 25);
i want to get people who are age 25 and who live in state = ny
The text was updated successfully, but these errors were encountered: