1.0.28 • Published 2 months ago

mongoose-operations v1.0.28

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

mongoose-operations

a set of mongoose-operations to create, find, update, count on a given connection

Table of Contents

Installation

$ npm i mongoose-operations

Features

  • Create new Data in Collection
  • Find all Fields in a Collection using Aggregate
  • Update specific Object keys
  • Count results by match

Create new Fields

Create new Data in Collection will return _id and existing Fields, if data already exists on indexed match

const mongoose = require('mongoose') //need to pass mongoose to prevent package dups
const mongooseOperations = require('mongoose-operations')
const instance = new mongooseOperations(mongoose)

const connection = DBConnect().model(
    TABLE,
    SCHEMA,
    TABLE)

module.exports = class {

createPackageMeta = async (title) => 
    await instance.create(
    { title: 'MyTitle' }, 
    connection
    )
}

return if title already exists

{
  e: 11000,
  _id: new ObjectId("64e9c309a90689fbecefb465"),
  title: 'MyTitle',
}
1.0.26

2 months ago

1.0.28

2 months ago

1.0.27

2 months ago

1.0.25

2 months ago

1.0.24

2 months ago

1.0.22

5 months ago

1.0.23

5 months ago

1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

7 months ago

1.0.21

6 months ago

1.0.20

6 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago