Skip to content

Commit 6702630

Browse files
committed
(Docs): Better explain about $meteor.object selector
Show that $meteor.object selector gets a selector as the second parameter and not just ID. Addresses Urigo#273
1 parent 8b0acbe commit 6702630

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

.docs/angular-meteor/client/views/api/api.meteorObject.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
# $meteor.object
1212

1313
A service that wraps a Meteor object to enable reactivity within AngularJS.
14+
Finds the first document that matches the selector, as ordered by sort and skip options.
15+
Wraps [collection.findOne](http://docs.meteor.com/#/full/findone)
1416

1517
----
1618

1719
## Usage
1820

19-
$meteor.object(collection, id, auto)
21+
$meteor.object(collection, selector, auto)
2022

2123
### Arguments
2224

@@ -43,9 +45,12 @@
4345
<td></td>
4446
</tr>
4547
<tr>
46-
<td>id</td>
47-
<td><a href="" class="label type-hint type-hint-string">string</a></td>
48-
<td><p>The Id of the object to bind to</p></td>
48+
<td>selector</td>
49+
<td><a href="" class="label type-hint type-hint-string">Mongo Selector, Object ID, or String</a></td>
50+
<td><p>A query describing the documents to find or just the ID of the document.
51+
$meteor.object will find the first document that matches the selector,
52+
as ordered by sort and skip options, exactly like Meteor's <a href="http://docs.meteor.com/#/full/findone">collection.findOne</a>
53+
</p></td>
4954
<td><a href="" class="label type-hint type-hint-array">Yes</a></td>
5055
<td></td>
5156
</tr>
@@ -106,6 +111,9 @@
106111
$scope.partyNotAuto.reset();
107112
};
108113

114+
// Query selector example
115+
$scope.partyOfUser = $meteor.object(Parties, {userId: Meteor.userId()});
116+
109117
}]);
110118
}
111119

.docs/angular-meteor/client/views/steps/tutorial.step_06.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ <h1>Step 6 - Bind one object</h1>
4343

4444
$meteor.object returns an [AngularMeteorObject](/api/meteorObject) that contains the data.
4545

46+
$meteor.object accepts a selector as the second argument.
47+
48+
That selector can be Mongo Selector, Object ID, or String.
49+
50+
In our example we used the Object's ID but it can also come in the form of {field: query}.
51+
52+
$meteor.object will find the first document that matches the selector,
53+
as ordered by sort and skip options, exactly like Meteor's [collection.findOne](http://docs.meteor.com/#/full/findone)
54+
4655

4756
# Template
4857

0 commit comments

Comments
 (0)