Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

damless-mongo

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

damless-mongo

Mongo client for damless

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

damless-mongo

Mongo service for damless.

NPM Build Status Coverage Status

Features

REST api

MethodParamDamLess method
GET/:idhttpFindOne
GET/?httpFind
POSThttpInsertOne
PUT/:idhttpSaveOne
PATCH/:idhttpUpdateOne with $set
DELETE/:idhttpDeleteOne

Create an api

const { Http } = require("damless-mongo");
class Api extends Http {

    //giveme is the dependency injection service used by damless
    constructor(giveme) {
        super(giveme, "<collectionName>");
    };

    ...
}

Http methods

MethodDescription
httpFindOne
httpFind
httpInsertOne
httpInsertMany
httpSaveOne
httpUpdateOne
httpSaveMany
httpUpdateMany
httpDeleteOne
httpDeleteMany
httpCount
httpAggregate

Stream methods

MethodDescription
saveOne
save
insertOne
insert
updateOne
update
replaceOne
deleteOne
delete
findOne
find
aggregate
count

Mongo api methods

MethodDescription
mongoInsertOne
mongoInsertMany
mongoAggregate
mongoBulkWrite
mongoCreateIndex
mongoCreateIndexes
mongoCount
mongoCreateIndexes
mongoDeleteOne
mongoDeleteMany
mongoDistinct
mongoDrop
mongoDropIfExists
mongoDropIndex
mongoDropIndexes
mongoFindOne
mongoFind
mongoFindOneAndDelete
mongoFindOneAndReplace
mongoFindOneAndUpdate
mongoGeoHaystackSearch
mongoGeoNear
mongoGroup
mongoMapReduce
mongoReplaceOne
mongoSave
mongoUpdateOne
mongoUpdateMany

Cutomize your api

const { Http } = require("damless-mongo");
const { promisify } = require("util");
const stream = require("stream");
const pipeline = promisify(stream.pipeline);

class Api extends Http {

    // giveme is the dependency injection service used by damless
    constructor(giveme) {
        super(giveme, "<collectionName>");
    };

    // override the default httpFind an use Crud primitives
    async httpFind(context, stream, headers) {
        // get a mongo cursor
        const cursor = this.findWords(context.query.q);
        await pipeline(
            cursor,
            stream
        );
    }
}

Add the mongo connection string in damless.json

{
	"mongo": {
        "connectionString": "mongodb://localhost:27017/database"
    },
}

Inject damless-mongo service

{
  "services": [
    { "name": "mongo", "location": "damless-mongo" }
  ]
}

Or in javascript

const DamLess = require("damless");
const damless = new DamLess();
damless.inject("mongo", "damless-mongo");

Installation

$ npm install damless-mongo

Test

To run our tests, clone the damless-mongo repo and install the dependencies.

$ git clone https://github.com/BenoitClaveau/damless-mongo --depth 1
$ cd damless-mongo
$ npm install
$ mongod --dbpath ./data/db
$ node.exe "../node_modules/mocha/bin/mocha" tests

Keywords

FAQs

Package last updated on 02 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc