1.0.31 • Published 8 months ago

mongoose-operations v1.0.31

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

mongoose-operations

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

Changelog

#Added createOrUpdate
await createOrUpdate({
      content: 'content',
      file: {
        size,
        data: buffer,
        contentType: mimetype,
      }
    }, 'connection')

    return { status, _id } 
    //200 created
    //201 updated

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
  • Delete Row by ID

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.31

8 months ago

1.0.30

9 months ago

1.0.29

1 year ago

1.0.26

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.22

2 years ago

1.0.23

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago