Adds the Scope.$populate
method that enables multiple record resolving using one request.
This plugin requires special api support for multiple id requests.
- Source:
- plugins/find-many.js, line 1
Methods
-
<static> $findManyUrl()
-
Provides the url for a findMany/populate operation.
- Source:
- plugins/find-many.js, line 17
-
<static> $populate(_records) → {Resource}
-
Resolves a series of records using a single api call.
By default, this method uses the same url used by
collection.$fetch
. To provide a different url then override theScope.$findManyUrl
function.By default this method uses the pluralized variat of the primary key for the query parameter holding the ids. You can override this parameter by setting the
findManyKey
configuration var.This method triggers the
before-find-many
event before sending the server request.Usage:
var bikes = [ Bike.$new(1), Bike.$new(2), Bike.$new(3) ]; Bike.$populate(bikes).$then(function() { // populate returns a fully fledged resource! alert('Ready!'); })
Parameters:
Name Type Description _records
array Records to resolve.
- Source:
- plugins/find-many.js, line 26
Returns:
Resource holding the populate promise.
- Type
- Resource