Skip to content

Commit

Permalink
9.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Nov 23, 2020
1 parent e4c74b4 commit 612f481
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 31 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### X.X.X (comming soon)

### 9.10.1 (23 November 2020)

Other:
- Additional refactorings to improve collection creation speed

Expand Down
22 changes: 17 additions & 5 deletions dist/es/rx-collection.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions dist/es/rx-database.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions dist/lib/rx-collection.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions dist/lib/rx-database.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 26 additions & 9 deletions dist/rxdb.browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -6016,7 +6016,11 @@ var RxCollectionBase = /*#__PURE__*/function () {

var _proto = RxCollectionBase.prototype;

_proto.prepare = function prepare() {
_proto.prepare = function prepare(
/**
* set to true if the collection data already exists on this storage adapter
*/
wasCreatedBefore) {
var _this = this;

this.pouch = this.database._spawnPouchDB(this.name, this.schema.version, this.pouchSettings);
Expand All @@ -6025,11 +6029,19 @@ var RxCollectionBase = /*#__PURE__*/function () {
this._keyCompressor = _overwritable.overwritable.createKeyCompressor(this.schema);
} // we trigger the non-blocking things first and await them later so we can do stuff in the mean time

/**
* Sometimes pouchdb emits before the instance is useable.
* To prevent random errors, we wait until the .info() call resolved
*/

var spawnedPouchPromise = this.pouch.info(); // resolved when the pouchdb is useable

var createIndexesPromise = _prepareCreateIndexes(this.asRxCollection, spawnedPouchPromise);
var spawnedPouchPromise = wasCreatedBefore ? Promise.resolve() : this.pouch.info();
/**
* if wasCreatedBefore we can assume that the indexes already exist
* because changing them anyway requires a schema-version change
*/

var createIndexesPromise = wasCreatedBefore ? Promise.resolve() : _prepareCreateIndexes(this.asRxCollection, spawnedPouchPromise);
this._crypter = (0, _crypter.createCrypter)(this.database.password, this.schema);
this._observable$ = this.database.$.pipe((0, _operators.filter)(function (event) {
return event.collectionName === _this.name;
Expand Down Expand Up @@ -6845,7 +6857,7 @@ function _prepareCreateIndexes(rxCollection, spawnedPouchPromise) {
*/


function create(_ref) {
function create(_ref, wasCreatedBefore) {
var database = _ref.database,
name = _ref.name,
schema = _ref.schema,
Expand Down Expand Up @@ -6879,7 +6891,7 @@ function create(_ref) {
});
});
var collection = new RxCollectionBase(database, name, schema, pouchSettings, migrationStrategies, methods, attachments, options, cacheReplacementPolicy, statics);
return collection.prepare().then(function () {
return collection.prepare(wasCreatedBefore).then(function () {
// ORM add statics
Object.entries(statics).forEach(function (_ref2) {
var funName = _ref2[0],
Expand Down Expand Up @@ -7216,7 +7228,7 @@ var RxDatabaseBase = /*#__PURE__*/function () {
hookData.database = _this3;
hookData.name = name;
(0, _hooks.runPluginHooks)('preCreateRxCollection', hookData);
return (0, _rxCollection.create)(useArgs);
return (0, _rxCollection.create)(useArgs, !!internalDoc);
}));

case 9:
Expand Down Expand Up @@ -7255,15 +7267,20 @@ var RxDatabaseBase = /*#__PURE__*/function () {
}
}); // make a single call to the pouchdb instance

_context.next = 15;
if (!(bulkPutDocs.length > 0)) {
_context.next = 16;
break;
}

_context.next = 16;
return pouch.bulkDocs({
docs: bulkPutDocs
});

case 15:
case 16:
return _context.abrupt("return", ret);

case 16:
case 17:
case "end":
return _context.stop();
}
Expand Down
2 changes: 1 addition & 1 deletion dist/rxdb.browserify.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/types/rx-collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export declare class RxCollectionBase<RxDocumentType = {
*/
private _onDestroy?;
private _onDestroyCall?;
prepare(): Promise<[any, any]>;
prepare(
/**
* set to true if the collection data already exists on this storage adapter
*/
wasCreatedBefore: boolean): Promise<[any, any]>;
migrationNeeded(): Promise<boolean>;
getDataMigrator(): DataMigrator;
migrate(batchSize?: number): Observable<MigrationState>;
Expand Down Expand Up @@ -157,7 +161,7 @@ export declare class RxCollectionBase<RxDocumentType = {
/**
* creates and prepares a new collection
*/
export declare function create({ database, name, schema, pouchSettings, migrationStrategies, autoMigrate, statics, methods, attachments, options, cacheReplacementPolicy }: any): Promise<RxCollection>;
export declare function create({ database, name, schema, pouchSettings, migrationStrategies, autoMigrate, statics, methods, attachments, options, cacheReplacementPolicy }: any, wasCreatedBefore: boolean): Promise<RxCollection>;
export declare function isInstanceOf(obj: any): boolean;
declare const _default: {
create: typeof create;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rxdb",
"description": "A realtime Database for JavaScript applications",
"version": "9.10.0",
"version": "9.10.1",
"author": "pubkey",
"repository": {
"type": "git",
Expand Down

0 comments on commit 612f481

Please sign in to comment.