rafamel / rxdb-utils

RxDB's missing pieces
MIT License
69 stars 5 forks source link

Add greater flexibility in timestamps #12

Closed tommyo closed 4 years ago

tommyo commented 4 years ago

This adds a few features, but is 100% backwards compatible:

  1. options can be set on the database rather than individual collections, and can be overridden by collection.

    const db = await RxDB.create({
    name: 'examples',
    options: { timestamps: true }
    });
    const users = await db.collection({
    name: 'items',
    ...
    options: { timestamps: false }
    });
  2. options at both levels can accept field name overrides:

    const db = await RxDB.create({
    name: 'examples',
    options: { 
    timestamps: {
      createdAt: 'created',
      updatedAt: 'modified'
    }
    }
    });

Unit tests included.

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 33


Totals Coverage Status
Change from base Build 27: -0.3%
Covered Lines: 365
Relevant Lines: 371

💛 - Coveralls
rafamel commented 4 years ago

Looks good, any chance you can add it to the README so it's documented before merging?

rafamel commented 4 years ago

I've merged for now as I'm making some substantial changes to the project's setup. I've had this module stagnant for a long while and I'm cleaning it up a little. As of now, the tests are failing for replication after the changes introduced in this PR for named custom fields. I would recommend you do a pull from the latest master, npm install, and go from there.

rafamel commented 4 years ago

The issue with replication custom fields are fixed on the latest commit ;)