3.0.2 • Published 6 years ago

knorm-timestamps v3.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

knorm-timestamps

npm version build status coverage status dependency status Greenkeeper badge

Timestamps plugin for knorm.

This plugin adds the knex timestamp fields to your models and also updates your query methods so that createdAt and updatedAt are set to the current time (i.e. new Date()) for insert calls and the updatedAt field is set to the current time for any update calls. It will also ensure that any update calls do not overwrite the createdAt field.

Installation

npm install --save knorm knorm-timestamps

knorm-timestamps has a peer dependency on knorm

Usage

const knorm = require('knorm');
const knormTimestamps = require('knorm-timestamps');

const orm = knorm({
  // knorm options
}).use(
  knormTimestamps({
    // knormTimestamps options
  })
);

Options

createdAt

type: object, default: { name: 'createdAt', column: 'created_at' }

The createdAt field can be configured with these options:

  • name string, default: createdAt: the field name
  • column string, default: created_at: the column name

updatedAt

type: object, default: { name: 'updatedAt', column: 'updated_at' }

The updatedAt field can be configured with these options:

  • name string, default: updatedAt: the field name
  • column string, default: updated_at: the column name
3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago