Closed kalimantos closed 8 years ago
Yes.
Hi, i'm using that that store schema:
{
name: 'contact',
keyPath: 'contactid',
indexes: [
{
name: 'accountid, name',
//keyPath: ['accountid', 'name'],
generator: function (obj) {
return [
obj.accountid,
obj.name.toUpperCase()
];
}
}
]
}
if i use the keyPath all is ok, but if i use the generator, an error was given when i istantiate the db with
var db = ydn.db.Storage(config.dbName, dbSchema, {
mechanisms: ['indexeddb', 'websql']
});
the error is:
How can i make it work? Thank you
Then it is a bug.
Fixed in release 1.4.1. Thanks.
Thank you so much!!
Hi! i'm having some problems while query using the index under
{
name: 'contact',
keyPath: 'contactid',
indexes: [
{
name: 'accountid, name',
//keyPath: ['accountid', 'name'],
generator: function (obj) {
return [
obj.accountid,
obj.name.toUpperCase()
];
}
}
]
}
if i query using that code:
//accountId is a string assuming the value of the account i need to filter
db.from('contact')
.where('accountid', '=', accountId)
.order('name')
.list()
.done(function(l){console.log(l)});
that error is raised: Uncaught ConstraintError: Require index "accountid, name" not found in store "contact"
How can i solve that? Thank you so much
replacing
//accountId is a string assuming the value of the account i need to filter
db.from('contact')
.where('accountid', '=', accountId)
.order('name')
.list()
.done(function(l){console.log(l)});
with
var keyRange = ydn.db.KeyRange.starts([accountid]);
db.values('contact', 'accountid, name', keyRange).done(function(l){console.log(l)});
it works!
@kalimantos looks like bug in Query.
Hi, i know that it's possible to use generator for create an index with one field, for example:
but can i create a index with more than one field? (as using keyPath: ['myField1', 'myField2']) maybe as this?
thanks in advance!