12.0.0 • Published 4 months ago

volante-mongo v12.0.0

Weekly downloads
11
License
ISC
Repository
github
Last release
4 months ago

Volante MongoDb Spoke

volante module for mongodb

Provides simple connection using the native mongodb node.js driver. All events follow the Volante hub/spoke model and are emitted on the hub.

Usage

npm install volante-mongo

Volante modules are automatically loaded and instanced if they are installed locally and hub.attachAll() is called.

Props

Options are changed using the VolanteMongo.update event with an options object:

hub.emit('VolanteMongo.update', {
  dbhost: "127.0.0.1",  // mongod address
  dbopts: {},           // options object passed to driver on connect
  retryInterval: 10000, // retry timeout when mongo connection lost
  handleCrud: false,    // flag to enable generid crud handlers (volante.read, etc...)
});

The module will automatically start a connection when the props are changed.

Events

Handled

  • VolanteMongo.connect - start connection, only useful if using the defaults

Mongo API

  • mongo.insertOne
    String, // the full namespace (e.g. db.collection)
    Object, // the document to create
    Function // the callback to call when the operation is complete
  • mongo.find
    String, // the full namespace (e.g. db.collection)
    Object, // the object to use as a query (this may include implementation-specific constructs)
    Function // the callback to call when the operation is complete
  • mongo.updateOne
    String, // the full namespace (e.g. db.collection)
    String, // the _id of the object to update
    Object, // the update operation (see https://docs.mongodb.com/manual/reference/operator/update/)
    Function // the callback to call when the operation is complete
  • mongo.deleteOne
    String, // the full namespace (e.g. db.collection)
    String, // the _id of the object to delete
    Function // the callback to call when the operation is complete
  • mongo.aggregate
    String, // the full namespace (e.g. db.collection)
    Array, // the aggregation pipeline (see https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/)
    Function // the callback to call when the operation is complete
  • mongo.watch
    String, // the full namespace (e.g. db.collection)
    Array, // the aggregation pipeline used to filter for ChangeStream events
    Function // the callback to call when watch operation is triggered

CRUD Handling

When handleCrud is set to true, VolanteMongo will handle the following Volante CRUD interface:

  • volante.create
    String, // the name of the collection/table/directory
    Object, // the object to create
    Function // the callback to call when the operation is complete
  • volante.read
    String, // the name of the collection/table/directory
    Object, // the object to use as a query (this may include implementation-specific constructs)
    Function // the callback to call when the operation is complete
  • volante.update
    String, // the name of the collection/table/directory
    String, // the `id` of the object to update
    Object, // an object containing either the full replacement content, or implementation-specific update mechanisms
    Function // the callback to call when the operation is complete
  • volante.delete
    String, // the name of the collection/table/directory
    String, // the `id` of the object to delete
    Function // the callback to call when the operation is complete

Emitted

In addition to native Volante log events, this modules also emits:

  • VolanteMongo.connected - on connected
  • VolanteMongo.disconnected - on disconnect or connection loss

License

ISC

12.0.0

4 months ago

11.0.1

9 months ago

10.4.1

1 year ago

10.4.2

1 year ago

10.4.3

1 year ago

10.4.4

1 year ago

10.4.5

1 year ago

11.0.0

1 year ago

10.5.0

1 year ago

10.0.0

2 years ago

10.0.1

2 years ago

10.2.0

2 years ago

10.4.0

1 year ago

10.1.0

2 years ago

10.3.0

1 year ago

10.3.1

1 year ago

9.2.2

2 years ago

9.3.0

2 years ago

9.2.1

2 years ago

9.1.0

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

9.2.0

2 years ago

9.0.0

2 years ago

6.4.1

2 years ago

6.4.0

2 years ago

7.0.0

2 years ago

6.3.1

3 years ago

6.3.0

3 years ago

6.1.0

3 years ago

6.2.1

3 years ago

6.2.0

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.10.1

3 years ago

5.10.0

3 years ago

5.9.2

3 years ago

5.9.1

3 years ago

5.9.0

3 years ago

5.8.0

3 years ago

5.7.0

3 years ago

5.6.1

3 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.6.0

3 years ago

5.5.0

3 years ago

5.4.0

3 years ago

5.3.0

3 years ago

5.2.0

3 years ago

5.1.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.5

4 years ago

4.1.4

4 years ago

4.1.3

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.4.0

4 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago