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

node-simple-collectionmodel

Package Overview
Dependencies
Maintainers
0
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-simple-collectionmodel

A simpel and nice collection model for mongoose stuff.

  • 1.3.45
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-95.16%
Maintainers
0
Weekly downloads
 
Created
Source

A Node.js collection model for mongoose stuff

Build Status Coverage Status GitHub version npm version

TL;DR

Installation

npm install node-simple-collectionmodel --save

Usage Express Style

Add schemas for all collections you want to use.

Create a Mongoose init file MongooseHelper:

const { CollectionModel } = require('node-simple-collectionmodel');

const loginUserSchema = require('./loginUserSchema');
const sequenceSchema = require('./sequenceSchema');

CollectionModel.addSchemas({
    loginUser: loginUserSchema,
    sequence: sequenceSchema,
});

module.exports = CollectionModel;

Then extend your collection classes.

const { CollectionModel } = require('node-simple-collectionmodel');

class LoginUser extends CollectionModel {
    constructor(config) {
        super('loginUser', config);
        this.searchFields = ['email'];
        this.searchFieldsNum = ['id'];
        this.defaultSort = { email: -1 };
    }
}

module.exports = LoginUser;

Connection to the database globally inside server startup.

const CollectionModel = require('./MongooseHelper');

CollectionModel.connectGlobal({
    config: {
        mongo: {
            url: 'mongodb://localhost:27017/mySuperDB?safe=true&auto_reconnect=true&poolSize=20'
        }
    }
});

Usage of collection class.

const email = 'sorenso@gmail.com';
const loginUser = new LoginUser();
myUser = await loginUser.findOne({ email });
console.log(myUser);

Helper modules in use:

Jest A browser JavaScript testing toolkit. Jest is used by Facebook to test all JavaScript code including React applications. One of Jest's philosophies is to provide an integrated "zero-configuration" experience.

ESLint ESLint is a code style linter for programmatically enforcing your style guide.

Travis Travis CI is a hosted continuous integration service. It is integrated with GitHub and offers first class support for many languages.

Coveralls.io Coveralls is a web service to help you track your code coverage over time, and ensure that all your new code is fully covered.

Retire Scanner detecting the use of JavaScript libraries with known vulnerabilities.

Howto to get started with contributions

$ git clone git@github.com:5orenso/node-simple-collectionmodel.git
$ cd node-simple-collectionmodel/
$ npm install

Start developing. Remember to start watching your files:

$ npm run test:watch

HOWTO fix eslint issues

$ eslint --fix lib/utilities.js

Howto contribute

$ git clone git@github.com:5orenso/node-simple-collectionmodel.git

Do your magic and create a pull request.

Howto report issues

Use the Issue tracker

Howto update CHANGELOG.md

$ bash ./changelog.sh

Howto update NPM module

  1. Bump version inside package.json
  2. Push all changes to Github.
  3. Push all changes to npmjs.com: $ bash ./npm-release.sh.

Howto check for vulnerabilities in modules

# Install Node Security Platform CLI
$ npm install nsp --global  

# From inside your project directory
$ nsp check  

Howto upgrade modules

$ sudo npm install -g npm-check-updates
$ ncu -u -a
$ npm install --no-optional

Versioning

For transparency and insight into the release cycle, releases will be numbered with the follow format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit http://semver.org/.

Contributions and feedback:

We ❤️ contributions and feedback.

If you want to contribute, please check out the CONTRIBUTING.md file.

If you have any question or suggestion create an issue.

Bug reports should always be done with a new issue.

Other Resources

More about the author

FAQs

Package last updated on 30 Aug 2024

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