Skip to main content
added 9 characters in body
Source Link
Lutz
  • 133
  • 6

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really unneeded complicated. It's a failure in design. This forces the developer to do things like in relatedrelational DBs, but WITHOUTwhile lacking all the possibilities of SQL. Really bad :(

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really unneeded complicated. It's a failure in design. This forces the developer to do things like in related DBs, but WITHOUT the possibilities of SQL. Really bad :(

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really unneeded complicated. It's a failure in design. This forces the developer to do things like in relational DBs, while lacking all the possibilities of SQL. Really bad :(

Summ
Source Link
Lutz
  • 133
  • 6

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really much moreunneeded complicated. It's a failure in design. This forces the developer to do things like in related DBs, but WITHOUT the possibilities of SQL. Really bad :(

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really much more complicated.

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really unneeded complicated. It's a failure in design. This forces the developer to do things like in related DBs, but WITHOUT the possibilities of SQL. Really bad :(

added 131 characters in body
Source Link
Lutz
  • 133
  • 6

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really much more complicated.

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Answering my own question: I have made some tests now. It looks like it is not possible to do this with that object in only 1 objectStore.

An other example object which would work:

var myObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "shipping": {"method": "letter",
                 "company": "Deutsche Post AG" }
}

Creating an index will be done by:

objectStore.createIndex(objectIndexName, objectKeypath, optionalObjectParameters);

With setting objectKeypath it is possible to address a value in the main object like "name":

objectStore.createIndex("name", "name", {unique: false});

It would also be possible to address a value form a subobject of an object like "shipping.method":

objectStore.createIndex("shipping", "shipping.method", {unique: false});

BUT it is not possible to address values like the ones of "track", which are contained in objects, stored in an array. Even something like "parcels[0].track" to get the first value as index does not work.

Anyhow, it would be possible to index all simple elements of an array (but not objects).

So the following more simple structure would allow to create an index entry for each parcelnumber in the array "trackingNumbers":

var simplifiedOrderObject = {
    "ordernumber": "123-12345-234",
    "name": "Mr. Sample",
    "address": "Foostreet 12, 12345 Bar York",
    "orderitems": [
        {
            "item": "brush",
            "price": "2.00"
        },
        {
            "item": "phone",
            "price": "30.90"
        }
    ],
    "trackingNumbers": ["12345", "3254231514"]
} 

when creating the index with multiEntry set to true:

objectStore.createIndex("tracking", "trackingNumbers", {unique: false, multiEntry: true});

Anyhow, the missing of the possibility to index object values in arrays, makes using indexedDB really much more complicated.

deleted 12 characters in body
Source Link
Lutz
  • 133
  • 6
Loading
added 2 characters in body
Source Link
Lutz
  • 133
  • 6
Loading
deleted 1 character in body
Source Link
Lutz
  • 133
  • 6
Loading
added 12 characters in body
Source Link
Lutz
  • 133
  • 6
Loading
added 86 characters in body
Source Link
Lutz
  • 133
  • 6
Loading
added 86 characters in body
Source Link
Lutz
  • 133
  • 6
Loading
Source Link
Lutz
  • 133
  • 6
Loading