How to use the rxdb/plugins/core.isRxCollection function in rxdb

To help you get started, we’ve selected a few rxdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johannesjo / super-productivity / src / app / core / rxdb / ngx-rxdb.service.ts View on Github external
async createCollection(schemaConfig: NgxRxdbCollectionConfig) {
    console.log('CREATE COLLECTION');

    // TODO this needs to be fixed to be available initially
    await promiseTimeout(2500);

    if (!schemaConfig || !schemaConfig.schema) {
      throw new Error('RxdbService: missing schema object');
    }
    let collection: RxCollection = this.db[name];
    // delete collection if exists
    if (RxDB.isRxCollection(collection)) {
      console.log('RxdbService: collection', name, 'exists, skip create');
      await collection.remove();
    }
    collection = await this.db.collection(new NgxRxdbCollectionCreator(schemaConfig));
    console.log(`RxdbService: created collection "${name}"`);
    // preload data into collection
    const docsCount = await collection.countAllDocuments();
    console.log(`RxdbService: collection "${name}" has "${parseInt(docsCount, 0)}" docs`);
    if (schemaConfig.options && schemaConfig.options.initialDocs && !!!docsCount) {
      const dumpObj = {
        name,
        schemaHash: collection.schema.hash,
        encrypted: false,
        docs: [...schemaConfig.options.initialDocs],
      };
      await collection.importDump(dumpObj);
github johannesjo / super-productivity / src / app / core / rxdb / ngx-rxdb.service.ts View on Github external
getCollection(name: string): RxCollection {
    const collection: RxCollection = this.db[name];
    if (RxDB.isRxCollection(collection)) {
      return collection;
    } else {
      console.warn(`RxdbService: returned false for RxDB.isRxCollection(${name})`);
      return null;
    }
  }
github johannesjo / super-productivity / src / app / core / rxdb / ngx-rxdb-collection.service.ts View on Github external
public get collection() {
    if (RxDB.isRxCollection(this._collection)) {
      return this._collection;
    } else {
      console.warn(`RxdbService: returned false for RxDB.isRxCollection(${this._config.name})`);
      return null;
    }
  }
github johannesjo / super-productivity / src / app / core / rxdb / ngx-rxdb.service.ts View on Github external
getAllDocs(name: string): Observable[]> {
    const collection: RxCollection = this.db[name];
    return RxDB.isRxCollection(collection) ? collection.find().$ : of([]);
  }

rxdb

A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/

Apache-2.0
Latest version published 20 days ago

Package Health Score

80 / 100
Full package analysis