-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpackage.json
More file actions
36 lines (36 loc) · 5.52 KB
/
package.json
File metadata and controls
36 lines (36 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"name": "magnolia",
"version": "0.0.5",
"description": "Beautiful MongoDB wrapper using Q",
"main": "index.js",
"scripts": {
"test": "tap test.js"
},
"repository": {
"type": "git",
"url": "git@github.com:Submersible/node-magnolia.git"
},
"keywords": [
"mongodb",
"mongo",
"q",
"promise",
"easy"
],
"author": {
"name": "Ryan Munro",
"email": "ryan@subc.io"
},
"license": "MIT",
"dependencies": {
"q": "~0.8.12",
"lodash": "~1.0.1",
"dsl": "0.0.2",
"mongodb": "~1.2.14"
},
"devDependencies": {
"tap": "~0.4.2"
},
"readme": "# magnolia–A beautiful MongoDB driver w/ Q [](http://travis-ci.org/Submersible/node-magnolia)\n\nMagnolia implements a coherent, lazy, & chainable interface... with promises!\nDon't nest callbacks anymore than you have to!\n\n## Init\n\nIf you don't mind state, you can init the module's state with default options.\n\n```javascript\nvar mongo = require('magnolia'),\n ObjectID = mongo.ObjectID;\n\nmongo\n .server({host: 'localhost', port: 27117)\n .db('hello')\n .options({w: 1})\n .init(); // makes all the previous calls stored as defaults\n```\n\nOr you can start a chain with the defaults you would like.\n\n```javascript\nvar mongo = require('magnolia')\n .server({host: 'localhost', port: 27117)\n .db('hello')\n .options({w: 1});\n```\n\n## Connection\n\n* `magnolia(collection, [db])`\n* `.collection(collection)`\n* `.db(db)`\n* `.server(server)`\n* `.options(...)`\n * `m:1`\n * `journal:true`\n * `fsync:true`\n * `slaveOk:true`\n\n## Find\n\n```javascript\nmagnolia('user')\n .filter({_id: ObjectID('4e4e1638c85e808431000003')}) // filter!\n .one() // just find one!\n .then(function (user) { // evaluate as a promise\n console.log('hello', user.name);\n });\n\nmagnolia('user')\n .filter({hello: 'world'})\n .toArray(function (err, docs) { /* ... */ });\n```\n\n* `.toArray([cb])` Query the collection, otherwise it will be lazily queried when you evaluate the chain as a promise\n* `.filter(criteria)` Filter the collection\n* `.one()` Find one! And return the document, instead of a list.\n* `.limit(n).skip(m)` to control paging.\n* `.sort(fields)` Order by the given fields. There are several equivalent syntaxes:\n * `.sort([['field1', 'desc'], ['field2', 'asc']])`\n * `.sort([['field1', 'desc'], 'field2'])`\n * `.sort('field1')` ascending by field1\n\n### Find and modifiy\n\n```javascript\nmagnolia('user')\n .filter(query)\n .sort(sort)\n .options(options)\n .findAndModify(objNew, [options], [callback]);\n```\n\nUseful options (including the previous options):\n\n* `.filter(...)`\n* `.sort(...)`\n* `.options(...)`\n * `remove:true` set to a true to remove the object before returning\n * `new:true` set to true if you want to return the modified object rather than the original. Ignored for remove.\n * `upsert:true` Atomically inserts the document if no documents matched.\n\n## Remove\n\n```javascript\nmagnolia('user')\n .filter(query)\n .remove(extra_query)\n .then(function (remove_count) { /* ... */ });\n```\n\n## Insert\n\n```javascript\nmagnolia('user')\n .insert({name: 'ryan', company: 'Submersible'}, {safe: true})\n .then(function (doc) { /* ... */ });\n\nmagnolia('user')\n .safe()\n .insert([{foo: 'bar'}, {hello: 'world'}], function (err, docs) {\n /* ... */\n });\n```\n\n* `.safe()` or `.unsafe()` Make sure document is in the database before returning\n* `.options(...)`\n * `safe:true`\n\n## Update; update and insert (upsert)\n\nSignature:\n\n```javascript\nmagnolia('user')\n .filter(criteria)\n .update(update, [options], [callback]);\n```\n\n```javascript\nmagnolia('user')\n .filter(criteria)\n .upsert(objNew, [options], [callback]);\n```\n\nUseful options:\n\n* `.filter(...)`\n* `.one()` or `.multi()`\n* `.safe()` or `.unsafe()`\n* `.options(...)`\n * `safe:true` Should always set if you have a callback.\n * `multi:true` If set, all matching documents are updated, not just the first.\n * `upsert:true` Atomically inserts the document if no documents matched.\n\n## Save\n\nPerforms an update if there's an `_id`, and an insert if not!\n\n```javascript\nmagnolia('user').save({_id: ObjectID('50c03c9c766c8598e0000002'), foo: 'bar'}); // update\nmagnolia('user').save({hello: 'world'}); // insert\n```\n\n## Count\n\n```javascript\nmagnolia('user').count([filter], [cb]);\n```\n\n## Map/reduce\n\n## Data types\n\n```javascript\nmagnolia.Long(numberString)\nmagnolia.ObjectID(hexString)\nmagnolia.Timestamp()\nmagnolia.DBRef(collectionName, id, dbName)\nmagnolia.Binary(buffer)\nmagnolia.Code(code, [context])\nmagnolia.Symbol(string)\nmagnolia.MinKey()\nmagnolia.MaxKey()\nmagnolia.Double(number)\n```\n\n## TODO\n\n1. Think of things that are left todo\n1. commands\n 1. insert DONE\n 1. remove DONE\n 1. update DONE\n 1. count DONE\n 1. upsert DONE\n 1. findAndModify DONE\n 1. toArray DONE\n 1. nextObject\n 1. each\n 1. ensureIndex?\n1. wtf is aggregation?\n 1. mapreduce\n1. db\n1. collection\n1. server\n1. wrap the data types\n1. can i test a bad connection?\n\n1. features\n 1. nextObject\n 1. each\n 1. ensureIndex\n 1. map/reduce\n 1. queueing, max connections\n 1. raw mongodb connection\n1. fix\n 1. find's limit & sort\n 1. does server work?\n\n\n\n## Check this\n\n1. think of the options, and what can be made coherent\n1. do it!\n1. write test for that method\n1. document\n",
"readmeFilename": "README.md"
}