stores: function()

in public/dexie.js [1726:1762]


      stores: function (stores) {
        /// <summary>
        ///   Defines the schema for a particular version
        /// </summary>
        /// <param name="stores" type="Object">
        /// Example: <br/>
        ///   {users: "id++,first,last,&amp;username,*email", <br/>
        ///   passwords: "id++,&amp;username"}<br/>
        /// <br/>
        /// Syntax: {Table: "[primaryKey][++],[&amp;][*]index1,[&amp;][*]index2,..."}<br/><br/>
        /// Special characters:<br/>
        ///  "&amp;"  means unique key, <br/>
        ///  "*"  means value is multiEntry, <br/>
        ///  "++" means auto-increment and only applicable for primary key <br/>
        /// </param>
        this._cfg.storesSource = this._cfg.storesSource
          ? extend(this._cfg.storesSource, stores)
          : stores;
        // Derive stores from earlier versions if they are not explicitely specified as null or a new syntax.
        var storesSpec = {};
        versions.forEach(function (version) {
          extend(storesSpec, version._cfg.storesSource);
        });
        var dbschema = (this._cfg.dbschema = {});
        this._parseStoresSpec(storesSpec, dbschema);
        // Update the latest schema to this version
        // Update API
        globalSchema = db._dbSchema = dbschema;
        removeTablesApi([allTables, db, Transaction.prototype]); // Keep Transaction.prototype even though it should be depr.
        setApiOnPlace(
          [allTables, db, Transaction.prototype, this._cfg.tables],
          keys(dbschema),
          dbschema
        );
        dbStoreNames = keys(dbschema);
        return this;
      },