Git Product home page Git Product logo

js-mongodb-utilities's Introduction

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

Category Status
Version npm
Dependencies David
Dev dependencies David
Build GitHub Actions
License GitHub

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.

js-mongodb-utilities's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar semantic-release-bot avatar strangedev avatar

Watchers

 avatar

Forkers

strangedev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.