1.0.31 • Published 1 year ago
mongoose-operations v1.0.31
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 updatedTable of Contents
Installation
$ npm i mongoose-operationsFeatures
- 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
1 year ago
1.0.30
1 year ago
1.0.29
2 years ago
1.0.26
2 years ago
1.0.28
2 years ago
1.0.27
2 years ago
1.0.25
2 years ago
1.0.24
2 years 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
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago