backbone-dynamodb.js
function fetchCollection(collection, options) {
	options || ( options = {} );

	var request,
		deferred = new _.Deferred(),
		// Determine the type of request: Query or Scan. Default is Scan.
		fetchType = options.query ? 'query' : 'scan',
		params = { TableName: collection._tableName() };

	wrapComplete( collection, options );
	_.extend( params, options[ fetchType ], options.dynamodb );

	// Create the Query or Scan request
	request = dynamo()[ fetchType ]( params );

	request.on('complete', function (response) {
		var dummyModel,
			ctx = options.context || collection;

		if ( response.error ) {
			deferred.rejectWith( ctx, [ response, options ] );
		} else {
			/**
			 * Backbone's "internal" success callback takes an array of models/objects as the first argument.
			 * Make the entire AWS `response` available as `options.awsResponse`.
			 * `Date` attributes are deserialized here.
			 */
			options.awsResponse = response;
			dummyModel = new collection.model();
			_.each(response.data.Items, function (item) {
				deserializeAllDates( dummyModel, item );
			});
			deferred.resolveWith( ctx, [ response.data.Items, options ] );
		}
	});
	request.send();

	deferred.done( options.success ).fail( options.error ).always( options.complete );

	return deferred.promise( request );
}
function fetchCollection(collection, options) {
	options || ( options = {} );

	var request,
		deferred = new _.Deferred(),
		// Determine the type of request: Query or Scan. Default is Scan.
		fetchType = options.query ? 'query' : 'scan',
		params = { TableName: collection._tableName() };

	wrapComplete( collection, options );
	_.extend( params, options[ fetchType ], options.dynamodb );

	// Create the Query or Scan request
	request = dynamo()[ fetchType ]( params );

	request.on('complete', function (response) {
		var dummyModel,
			ctx = options.context || collection;

		if ( response.error ) {
			deferred.rejectWith( ctx, [ response, options ] );
		} else {
			/**
			 * Backbone's "internal" success callback takes an array of models/objects as the first argument.
			 * Make the entire AWS `response` available as `options.awsResponse`.
			 * `Date` attributes are deserialized here.
			 */
			options.awsResponse = response;
			dummyModel = new collection.model();
			_.each(response.data.Items, function (item) {
				deserializeAllDates( dummyModel, item );
			});
			deferred.resolveWith( ctx, [ response.data.Items, options ] );
		}
	});
	request.send();

	deferred.done( options.success ).fail( options.error ).always( options.complete );

	return deferred.promise( request );
}
function fetchCollection ( collection , options ) { options || ( options = { } ) ; var request , deferred = new _ . Deferred ( ) , // Determine the type of request: Query or Scan. Default is Scan. fetchType = options . query ? 'query' : 'scan' , params = { TableName : collection . _tableName ( ) } ; wrapComplete ( collection , options ) ; _ . extend ( params , options [ fetchType ] , options . dynamodb ) ; // Create the Query or Scan request request = dynamo ( ) [ fetchType ] ( params ) ; request . on ( 'complete' , function ( response ) { var dummyModel , ctx = options . context || collection ; if ( response . error ) { deferred . rejectWith ( ctx , [ response , options ] ) ; } else { /**
			 * Backbone's "internal" success callback takes an array of models/objects as the first argument.
			 * Make the entire AWS `response` available as `options.awsResponse`.
			 * `Date` attributes are deserialized here.
			 */ options . awsResponse = response ; dummyModel = new collection . model ( ) ; _ . each ( response . data . Items , function ( item ) { deserializeAllDates ( dummyModel , item ) ; } ) ; deferred . resolveWith ( ctx , [ response . data . Items , options ] ) ; } } ) ; request . send ( ) ; deferred . done ( options . success ) . fail ( options . error ) . always ( options . complete ) ; return deferred . promise ( request ) ; }
Retrieves a collection of Backbone.DynamoDB.Models from a DynamoDB table using a Query or Scan request.

@param {Backbone.DynamoDB.Collection} collection The collection instance.
@param {Object} options The options object.
Retrieves a collection of Backbone . DynamoDB . Models from a DynamoDB table using a Query or Scan request .