0.3.19 • Published 6 years ago

ndx-mongo v0.3.19

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

ndx-mongo

mongo database connector for ndx-framework apps

Usage

npm install --save ndx-mongo

src/server/app.coffee

require 'ndx-server
  dbEngine: require 'ndx-mongo'
  mongoUrl: 'mongodb://192.168.99.100:27017/test'
  tables: ['users', 'table1', 'table2']
.start()

Environment variables

mongoUrl can be set with the environment variable MONGO_URL

Methods

db.select(string table, object whereObj, function callback)

Select data

db.insert(string table, object insertObj, function callback)

Insert data

db.update(string table, object updateObj, object whereObj, function callback)

Update data

db.upsert(string table, object upsertObj, object whereObj, function callback)

Upsert data

db.delete(string table, object whereObj, function callback)

Delete data

db.exec(string sql, array props, bool notCritical) -> data

Callbacks

ndx.database.on 'callbackName', (args, cb) ->
  #do something with args
  cb true #or false if you want to cancel the operation

ready

The database is ready to use

preInsert

  • args.table The database table being operated on
  • args.obj The object being inserted into the database
  • args.user The user carrying out the operation

cb(false) to cancel the insert

insert

  • args.id The inserted object's id
  • args.table The database table being operated on
  • args.obj The object that was inserted into the database
  • args.user The user carrying out the operation

preUpdate

  • args.id The id of the object being updated
  • args.table The database table being operated on
  • args.where The database query
  • args.obj The data to update
  • args.oldObj The value of the object preUpdate
  • args.changes The changes to be applied
  • args.user The user carrying out the operation

cb(false) to cancel the update

update

  • args.id The id of the object that was updated
  • args.table The database table that was operated on
  • args.obj The data that was updated
  • args.oldObj The value of the object pre update
  • args.newObj The value of the object post update
  • args.changes The changes that were applied
  • args.user The user carrying out the operation

preSelect

  • args.table The database table being operated on
  • args.args The arguments that were passed to the select function
  • args.user The user carrying out the operation

cb(false) to cancel the select

select

  • args.table The database table being operated on
  • args.objs The objects that were selected from the database
  • args.user The user carrying out the operation

preDelete

  • args.table The database table being operated on
  • args.where The database query
  • args.user The user carrying out the operation

cb(false) to cancel the delete

delete

  • args.table The database table being operated on
  • args.user The user carrying out the operation

callbacks can be used to modify data flowing to and from the database.
see ndx-permissions and ndx-profiler for examles

db.off(string callbackName, function callback) -> db

Unregister a callback

0.3.19

6 years ago

0.3.18

6 years ago

0.3.17

6 years ago

0.3.16

6 years ago

0.3.15

6 years ago

0.3.14

6 years ago

0.3.13

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago