@@ -10,7 +10,7 @@ We override the mutators from the Collection: `insert`, `update`, `upsert` and `
1010sent to the database.
1111
1212Let's take an example:
13- ```
13+ ``` js
1414const Items = new Mongo.Collection (' items' )
1515Items .insert ({text: ' Hello' })
1616```
@@ -19,7 +19,7 @@ After the insert is done into the database, we will publish to redis channel "it
1919that we did an insert, and the * _ id* of the document we inserted.
2020
2121For an update, things get a bit interesting in the back:
22- ```
22+ ``` js
2323Items .update (itemId, {
2424 $set: { text: ' Hello World!' }
2525})
@@ -31,7 +31,7 @@ The reason we do this will be explored later in this document. (Direct Processin
3131We send to redis the update event along with the document * _ id* and the fields that have been changed.
3232
3333If you choose to update multiple elements based on a selector:
34- ```
34+ ``` js
3535Items .update ({archived: false }, {
3636 $set: {archived: true }
3737}, {multi: true })
@@ -48,7 +48,7 @@ Removing something is almost the same concept as updates, except ofcourse the ev
4848
4949When you create a publication in Meteor you return a cursor or an array of cursors. For example:
5050
51- ```
51+ ``` js
5252Meteor .publish (' my_items' , function () {
5353 return Items .find ({userId: this .userId });
5454})
@@ -66,7 +66,7 @@ will share the same "watcher".
6666
6767There is another special use-case for listening to changes, and it is related to cursor that are filtered by _ ids. We call this "Direct Processing"
6868
69- ```
69+ ``` js
7070Meteor .publish (' items' , function () {
7171 return Items .find ({_id: {$in: ids}});
7272 // this has the same behavior when you have a selector like {_id: 'XXX'}
@@ -85,7 +85,7 @@ This is one of the most efficient ways to catch changes and process them. The co
8585
8686We extend the mutators ` insert ` , ` update ` and ` remove ` to allow an extra argument that configures the mutation.
8787
88- ```
88+ ``` js
8989// no changes will be published to any redis channels
9090Collection .insert (document , {pushToRedis: false })
9191Collection .update (selector, document , {pushToRedis: false })
0 commit comments