Creating stores with name as a parameter

23 views
Skip to first unread message

andrew....@gmail.com

unread,
Apr 21, 2016, 9:18:51 AM4/21/16
to Dexie.js
I have an array of strings where each string represents the name of a store I'd like to create in IndexedDB. All examples seem to suggest that the way to create stores is by specifying the store name as a property as in;

db.version(1).stores({
myObjectStore1: "primaryKey, index1, index2, ..." });

I have tried;

db.version(1).stores['myObjectStore1'] = "primaryKey, index1, index2, ...";

but that doesn't appear to work. Is there any way I'm able to achieve what I'm after using Dexie?

David Fahlander

unread,
Apr 21, 2016, 3:05:44 PM4/21/16
to andrew....@gmail.com, Dexie. js

You can convert an array of strings to an object with a little loop. For example like this: http://stackoverflow.com/questions/27412260/converting-string-array-into-a-key-value-pair-object

--
You received this message because you are subscribed to the Google Groups "Dexie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dexiejs+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/dexiejs.
To view this discussion on the web visit https://groups.google.com/d/msgid/dexiejs/6b77c964-9370-41bc-b07e-3b50efb8a55c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andrew....@gmail.com

unread,
Apr 22, 2016, 3:59:53 AM4/22/16
to Dexie.js, andrew....@gmail.com
I see the silly mistake I made. I should be creating a schema object and passing it into the stores function rather than trying to add a property to stores. Thanks for the help.
Reply all
Reply to author
Forward
0 new messages