store
fixture.store(baseItems, algebra)
Create a store that starts with baseItems
for a service layer
described by algebra
.
// Describe the services parameters:
const todoAlgebra = new set.Algebra(
set.props.id( "_id" ),
set.props.boolean( "completed" ),
set.props.rangeInclusive( "start", "end" ),
set.props.sort( "orderBy" ),
);
// Create a store with initial data.
// Pass [] if you want it to be empty.
const todoStore = fixture.store( [
{
_id: 1,
name: "Do the dishes",
complete: true
}, {
_id: 2,
name: "Walk the dog",
complete: false
} ],
todoAlgebra );
// Hookup urls to the store:
fixture( "/todos/{_id}", todoStore );
Parameters
Returns
{Store()}
:
A store that can be used to simulate a restful service layer that supports filtering, pagination, and more.
fixture.store(count, makeItems, algebra)
Similar to fixture.store(baseItems, algebra)
, except that
it uses makeItems
to create count
entries in the store.
// Describe the services parameters:
const todoAlgebra = new set.Algebra( /* ... */ );
// Create a store with initial data.
// Pass [] if you want it to be empty.
const todoStore = fixture.store(
1000,
function( i ) {
return {
_id: i + 1,
name: "Todo " + i,
complete: fixture.rand( [ true, false ], 1 )[ 0 ]
};
},
todoAlgebra );
// Hookup urls to the store:
fixture( "/todos/{_id}", todoStore );
Parameters
Returns
{Store()}
:
A store that can be used to simulate a restful service layer that supports filtering, pagination, and more.