npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongorito-timestamps

v1.0.1

Published

Created and updated timestamps for Mongorito

Downloads

10

Readme

mongorito-timestamps Build Status

Plugin to add "created" and "updated" timestamps for Mongorito models.

Installation

$ npm install --save mongorito-timestamps

Usage

const {Database, Model} = require('mongorito');
const timestamps = require('mongorito-timestamps');

class Post extends Model {}

const db = new Database('localhost/blog');
await db.connect();

db.use(timestamps());
db.register(Post);

const post = new Post({title: 'Hello'});
await post.save();

post.get('created_at');
//=> 2017-05-17T18:02:06.612Z

post.get('updated_at');
//=> same as `created_at`

post.set({title: 'World'});
await post.save();

post.get('created_at');
//=> same as previous `created_at`

post.get('updated_at');
//=> 2017-05-17T18:02:06.971Z

API

timestamps([options])

Configures and returns a timestamps plugin. Accepts an optional options object to customize field names and a function, which generates the timestamps.

options

createdAt

Type: string Default: created_at

Name of the field, which stores the date when the document was created. This field doesn't change after the initial creation.

updatedAt

Type: string Default: updated_at

Name of the field, which stores the date when the document was updated. This field changes on every save of the document.

getTimestamp

Type: function Default:

const getTimestamp = () => new Date();

Function, which generates a timestamp.

License

MIT © Vadim Demedes