You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's all there is to it! Now you can use any database reactively with Meteor!
62
62
63
-
##Bells and Whistles
63
+
# Bells and Whistles
64
64
65
-
###Publishing Cursors
65
+
## Publishing Cursors
66
66
67
67
This package can also publish any cursor that implements [`Cursor.observeChanges`][observeChanges]. Meteor's `mongo` pacakge works right out of the box:
68
68
@@ -94,7 +94,7 @@ I could use some help building drivers for reactive databases like Redis and Ret
94
94
All we need to do is implement `observeChanges` on a query cursor. There are also other
95
95
other tools for making MySQL and Postgres reactive as well.
96
96
97
-
###Publishing REST APIs
97
+
## Publishing REST APIs
98
98
99
99
This package is also suitable for publishing data continuously from REST APIs. Typically, you might use `Meteor.methods`, calling it periodically from the client using `Meteor.setInterval` to get updated results.
100
100
@@ -132,26 +132,26 @@ Template.events.events
132
132
events.trigger()
133
133
```
134
134
135
-
##Examples
135
+
# Examples
136
136
137
137
There are several [examples](/examples/) to check out, but most of them are really just end-to-end tests. The best example to check out is the [chatroom](/examples/chatroom/). This example uses Neo4j as a database to create a chatroom.
138
138
139
-
##How it works
139
+
# How it works
140
140
141
141
The codebase is actually pretty straightforward and I made sure to include LOTS of comments.
142
142
There are also plenty links to the Meteor codebase in the comments describing how I figured things out that are currently undocumented. Feel free to [dive in](/src/db.coffee)!
143
143
144
-
###Server
144
+
## Server
145
145
146
146
Each publication accepts a query function which must return a collection of documents that must contain a unique `_id` field. [DDP does not yet support ordered queries][DDP_spec] so every DDP message related to `addedBefore` or `movedBefore` has an additional (salted) key-value specifying the subscription and position.
147
147
148
-
###Client
148
+
## Client
149
149
150
150
On the client, we have an object, `DBSubscriptionCursor`, that encapsulates everything data-related in Meteor: `Meteor.subscribe`, `Mongo.Collection`, and `Mongo.Cursor`. We simple use `connection.registerStore` to register a data store and treat `DBSubscriptionCursor` as an observer, calling the appropriate [`Cursor.observeChanges`][observeChanges] method on each active subscription.
151
151
152
-
##Docs
152
+
# Docs
153
153
154
-
### `DB.publish(options)`
154
+
####`DB.publish(options)`
155
155
156
156
`options` object fields:
157
157
-`name`: name of the publication. (required)
@@ -192,7 +192,7 @@ Meteor.methods
192
192
```
193
193
194
194
195
-
### `sub = DB.createSubscription(name, args...)`
195
+
####`sub = DB.createSubscription(name, args...)`
196
196
197
197
This function returns a `DBSubscriptionCursor` object.
0 commit comments