2.0.19 • Published 3 years ago

@yeldirium/js-mongodb-utilities v2.0.19

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

JS Mongodb Utilities

This library is no longer maintained.


A collection of some small utility functions for easier interaction with the node.js mongodb driver.

Contains a small helper that connects to a database and some helpers that resolve references between documents.

npm install @yeldirium/js-mongodb-utilities
# or
yarn install @yeldirium/js-mongodb-utilities

Status

CategoryStatus
Versionnpm
DependenciesDavid
Dev dependenciesDavid
BuildGitHub Actions
LicenseGitHub

DbRef

A DbRef as defined by the utilities must match this schema:

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "title": "DBRef",
  "description": "A reference to an _id of another document",
  "type": "object",
  "properties": {
    "collection": {
      "description": "The collection the referenced object resides in",
      "type": "string"
    },
    "id": {
      "type": "string"
    }
  },
  "required": ["collection", "id"]
}

Where the value of collection must be the name of an existing collection and id must be the mongodb document _id of a document in said collection.

Then resolve can make your life easier by fetching the referenced documents for you in a controlled way using a list of allowed target collections and a maximum depth.

extractInsertedIdsFromMongoDBResult

Get the ids of created documents without having to look in the object yourself.

stripIds

String all mongodb document _ids from a document recursively. Useful, if you want to serve some documents from the database via an API but don't want to expose the internal ids.

2.0.19

3 years ago

2.0.18

3 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.12

4 years ago

2.0.11

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago