Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-timezone

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-timezone

[![Build Status](https://travis-ci.org/rodrigogs/mongoose-timezone.svg?branch=master)](https://travis-ci.org/rodrigogs/mongoose-timezone) [![Code Climate](https://codeclimate.com/github/rodrigogs/mongoose-timezone/badges/gpa.svg)](https://codeclimate.com/

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
247
decreased by-32.33%
Maintainers
1
Weekly downloads
 
Created
Source

mongoose-timezone

Build Status Code Climate Test Coverage dependencies Status devDependency Status npm npm version

A mongoose plugin to normalize stored dates timezone. By default mongo dates are stored in UTC format, this behaviour may cause problems when using advanced aggregation queries or when retrieving those dates from another system with different timezone.

mongoose-timezone basically adds the current timezone offset to the date before store and removes the offset when retrieving data. This way dates are kept proportional in the database and in the app.

Install

npm install mongoose-timezone --save

Usage

const mongoose = require('mongoose');
const timeZone = require('mongoose-timezone');

const Schema = new mongoose.Schema({
    date: Date,
    subDocument: {
        subDate: {
            type: Date,
        },
    },
});

// If no path is given, all date fields will be applied
Schema.plugin(timeZone, { paths: ['date', 'subDocument.subDate'] });
mongoose.model('Schema', Schema);

Notes

  • insertMany function is not supported due to mongoose's API limitations
  • update function is not supported due to mongoose's API limitations, save function could be used instead.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

Licence © Rodrigo Gomes da Silva

FAQs

Package last updated on 05 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc