This package has been deprecated

Author message:

this package is no longer maintained, please install @knorm/timestamps instead

knorm-timestamps

3.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i knorm-timestamps

Weekly Downloads

9

Version

3.0.2

License

MIT

Last publish

Collaborators

  • joelmukuthu