简体   繁体   English

有IndexedDb的标准命名约定吗?

[英]Is there a standard naming convention for IndexedDb?

Not looking for opinions here, but I'd like to know if any organization has released standards for naming JavaScript IndexedDb objects. 在这里不寻求意见,但我想知道是否有任何组织发布了用于命名JavaScript IndexedDb对象的标准。 I'm struggling to find anything beyond "unique" and "DOMString." 我正在努力寻找除“ unique”和“ DOMString”之外的任何东西。

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. 出于观察而不是提出意见,尝试以某种方式正式命名通用属性包与nosql dbs中的设计趋势背道而驰。

There is no explicit naming conventions in the RFC defining the IndexedDB standard , but in this document is used the following: RFC中没有定义IndexedDB标准的显式命名约定,但是在本文档中使用以下约定:

  • Database: camel case or all lowercase: library 数据库:驼峰式或全部小写: library
  • Object store: same, use the plural: books 对象存储:相同,使用复数: books
  • Object keys: camel case: title 对象键:骆驼盒: title
  • Index name: snake case, prefix the object key by "by": by_title 索引名称:蛇形外壳,在对象键之前加上“ by”: by_title

This slightly contradicts the MDN usage and the Google usage 这与MDN使用情况Google使用情况有些矛盾

  • Index name: no "by" prefix: title 索引名称:无“ by”前缀: 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: 由于IndexedDB是JS noSQL DB,MongoDB也是如此(相反,MongoDB明确建议使用命名约定),因此您还可以坚持以下原则:

  • Database: all lowercase, end by "db": librarydb 数据库:全部小写,以“ db”结尾: librarydb
  • Everything else: camel case: books , authorName 其他所有内容:骆驼案例: booksauthorName
  • Prefix by an underscore only when used internally, eg _id 仅在内部使用时,才使用下划线作为前缀,例如_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM