Is there a standard naming convention for IndexedDb?

Viewed 533

Not looking for opinions here, but I'd like to know if any organization has released standards for naming JavaScript IndexedDb objects. I'm struggling to find anything beyond "unique" and "DOMString."

2 Answers

There is no explicit naming conventions in the RFC defining the IndexedDB standard, but in this document is used the following:

  • Database: camel case or all lowercase: library
  • Object store: same, use the plural: books
  • Object keys: camel case: title
  • Index name: snake case, prefix the object key by "by": by_title

This slightly contradicts the MDN usage and the Google usage

  • Index name: no "by" prefix: title

Since IndexedDB is a JS noSQL DB and so is MongoDB (which, on the contrary, has explicitly recommended naming conventions), you can also stick to these:

  • Database: all lowercase, end by "db": librarydb
  • Everything else: camel case: books, authorName
  • Prefix by an underscore only when used internally, eg _id

If I understand your question correctly, I have not encountered any rules pertaining to naming of objects.

As an observation, and not an opinion, attempting to formally name a generic bag of properties a certain way runs counter to the design trend in nosql dbs.

Related