1
0
Fork 0

expose the any() method from the collection on the repository too

This commit is contained in:
Patrick Huber 2014-12-10 14:19:06 +01:00
parent 959631c4d9
commit d0eb69fc73
2 changed files with 24 additions and 0 deletions

View File

@ -138,6 +138,8 @@ var FulltextRepository = Foxx.Repository.extend({
@startDocuBlock JSF_foxx_repository_all
@startDocuBlock JSF_foxx_repository_any
!SUBSECTION Removing entries from the repository
@startDocuBlock JSF_foxx_repository_remove

View File

@ -273,6 +273,28 @@ _.extend(Repository.prototype, {
}, this);
},
////////////////////////////////////////////////////////////////////////////////
/// @startDocuBlock JSF_foxx_repository_any
/// `FoxxRepository#any()`
///
/// Returns a random document from this collection (or null if there is none).
///
/// @EXAMPLES
///
/// ```javascript
/// repository.any();
/// ```
/// @endDocuBlock
////////////////////////////////////////////////////////////////////////////////
any: function () {
'use strict';
var data = this.collection.any();
if (!data) {
return null;
}
return (new this.model(data));
},
// -----------------------------------------------------------------------------
// --SUBSECTION-- Removing Entries
// -----------------------------------------------------------------------------