0

I want to create multiple data store in one database in indexeddb.

I have created my database - College

Created a data store - Student

In the "College" database I want to create one more data store dynamically with the name "Department".

Is it possible? Please help me out.

Thanks in advance.

User 780611
  • 175
  • 1
  • 12

1 Answers1

2

In IndexedDB, a database can contain as many object stores as you'd like. So having "Department" and "Student" stores inside of a "College" database is no problem at all.

buley
  • 28,032
  • 17
  • 85
  • 106
  • Thanks for your comment, I am new to indexeddb, can you please provide me some link or syntax for creating multiple object store dynamically. – User 780611 Mar 18 '14 at 04:49
  • Here's the `maybeAddObjectStore()` method from [dash](http://dashdb.com/#docs), my IDB wrapper https://github.com/editor/dash/blob/master/lib/dash.dev.js#L915 – buley Mar 18 '14 at 12:31
  • 1
    No problem! Anything else I can help with to nudge you toward marking this as "correct"? – buley Apr 03 '14 at 12:39
  • I refer the link which u provided and one more link "http://stackoverflow.com/questions/20097662/how-to-create-multiple-objectstores-in-indexeddb", But getting error, DOM Exception, for which I have already posted a question. http://stackoverflow.com/questions/22604556/domexception-at-the-time-of-opendatabase-with-higher-version – User 780611 Apr 04 '14 at 08:52
  • Different question - different answer. I answered that one as well though: we need some more info about your error (such as `error.message` and the stack) – buley Apr 04 '14 at 13:42
  • I am getting DOM Exception here is what I am getting in console. `DBOpenDBRequest {onupgradeneeded: null, onblocked: null, onerror: null, onsuccess: null, readyState: "pending"…} error: [Exception: DOMException] onblocked: function () { console.log("blocked..."); } onerror: function () { console.log("error..."); } onsuccess: function () { console.log("success .. "); } onupgradeneeded: function (e2) { readyState: "pending" result: [Exception: DOMException] source: null transaction: null __proto__: IDBOpenDBRequest` – User 780611 Apr 07 '14 at 04:46
  • I know this is an old one, but the key fact here is as statet at https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/createObjectStore : *This method can be called only within a versionchange transaction.* . Very fooolish if u ask me :/ – Michael P Mar 23 '17 at 17:29