@@ -14,67 +14,77 @@ MongoDB adapter for [js-data](http://www.js-data.io/).
1414## Table of contents
1515
1616* [ Quick start] ( #quick-start )
17- * [ Documentation] ( #documentation )
18- * [ API Reference] ( #api-reference )
19- * [ Support] ( #support )
17+ * [ Guides and Tutorials] ( #guides-and-tutorials )
18+ * [ API Reference Docs] ( #api-reference-docs )
2019* [ Community] ( #community )
20+ * [ Support] ( #support )
2121* [ Contributing] ( #contributing )
2222* [ License] ( #license )
2323
2424## Quick Start
25- ` npm install --save js-data js-data-mongodb ` .
25+ ` npm install --save js-data js-data-mongodb mongodb bson ` .
2626
2727``` js
28- var JSData = require (' js-data' );
29- var DSMongoDBAdapter = require (' js-data-mongodb' );
30-
31- var store = new JSData.DS ();
32- var adapter = new DSMongoDBAdapter (' mongodb://localhost:27017' );
28+ // Use Container instead of DataStore on the server
29+ import {Container } from ' js-data'
30+ import MongoDBAdapter from ' js-data-mongodb'
31+
32+ // Create a store to hold your Mappers
33+ const store = new Container ({
34+ mapperDefaults: {
35+ // MongoDB uses "_id" as the primary key
36+ idAttribute: ' _id'
37+ }
38+ })
39+
40+ // Create an instance of MongoDBAdapter with default settings
41+ const adapter = new MongoDBAdapter ()
42+
43+ // Mappers in "store" will use the MongoDB adapter by default
44+ store .registerAdapter (' mongodb' , adapter, { default: true })
45+
46+ // Create a Mapper that maps to a "user" collection
47+ store .defineMapper (' user' )
48+ ```
3349
34- // "store" will now use the MongoDB adapter for all async operations
35- store .registerAdapter (' mongodb' , adapter, { default: true });
50+ ``` js
51+ async function findAllAdminUsers () {
52+ // Find all users where "user.role" == "admin"
53+ return await store .findAll (' user' , {
54+ role: ' admin'
55+ })
56+ }
57+ ```
3658
37- var User = store .defineResource ({
38- // Why couldn't Mongo just use "id"?
39- idAttribute: ' _id' ,
59+ ## Guides and Tutorials
4060
41- // map this resource to a collection, default is Resource#name
42- table: ' users'
43- });
44- ```
61+ [ Get started at http://js-data.io ] ( http://js-data.io )
4562
46- ### Documentation
47- - [ Getting Started with js-data] ( http://www.js-data.io/docs/home )
48- - [ js-data-mongodb] ( http://www.js-data.io/docs/js-data-mongodb )
49- - [ CHANGELOG.md] ( https://github.com/js-data/js-data-mongodb/blob/master/CHANGELOG.md )
63+ ## API Reference Docs
5064
51- ## API Reference
52- - [ js-data-mongodb] ( http://api.js-data.io/js-data-mongodb/ )
65+ [ Visit http://api.js-data.io ] ( http://api.js-data.io ) .
5366
54- ## Support
67+ ## Community
5568
56- Support questions are handled via [ StackOverflow] [ so ] , [ Slack] [ sl_l ] , and the
57- [ Mailing List] [ ml ] . Ask your questions there.
69+ [ Explore the Community] ( http://js-data.io/docs/community ) .
5870
59- When submitting bug reports on GitHub, please include as much detail as possible
60- to make debugging quick and easy.
71+ ## Support
6172
62- ## Community
63- - [ StackOverflow Channel] [ so ]
64- - [ Slack Chat] [ sl_l ] [ ![ Slack Status] [ sl_b ]] [ sl_l ]
65- - [ Announcements] ( http://www.js-data.io/blog )
66- - [ Mailing List] ( ml )
67- - [ Issue Tracker] ( https://github.com/js-data/js-data-mongodb/issues )
73+ [ Find out how to Get Support] ( http://js-data.io/docs/support ) .
6874
6975## Contributing
7076
71- See [ CONTRIBUTING.md ] ( https ://github.com/ js-data/js-data-mongodb/blob/master/CONTRIBUTING.md ) .
77+ [ Read the Contributing Guide ] ( http ://js-data.io/docs/contributing ) .
7278
7379## License
7480
7581The MIT License (MIT)
7682
77- See [ LICENSE] ( https://github.com/js-data/js-data-mongodb/blob/master/LICENSE ) .
83+ Copyright (c) 2014-2016 js-data-mongodb project authors
84+
85+ * [ LICENSE] ( https://github.com/js-data/js-data-mongodb/blob/master/LICENSE )
86+ * [ AUTHORS] ( https://github.com/js-data/js-data-mongodb/blob/master/AUTHORS )
87+ * [ CONTRIBUTORS] ( https://github.com/js-data/js-data-mongodb/blob/master/CONTRIBUTORS )
7888
7989[ sl_b ] : http://slack.js-data.io/badge.svg
8090[ sl_l ] : http://slack.js-data.io
@@ -88,6 +98,3 @@ See [LICENSE](https://github.com/js-data/js-data-mongodb/blob/master/LICENSE).
8898[ cov_l ] : https://coveralls.io/github/js-data/js-data-mongodb?branch=master
8999[ cod_b ] : https://img.shields.io/codacy/1f45ede49dfb4bdea68f46ca55631968.svg
90100[ cod_l ] : https://www.codacy.com/app/jasondobry/js-data-mongodb/dashboard
91-
92- [ ml ] : https://groups.io/org/groupsio/jsdata
93- [ so ] : http://stackoverflow.com/questions/tagged/jsdata
0 commit comments