DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
      • types
        • Store
        • ajaxSettings
        • request
        • requestHandler
        • response
      • properties
        • delay
        • on
        • rand
        • store
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-fixture
  • /
  • store
  • / On this page
    • store

      function
      • source

      fixture.store(baseItems, algebra)

      Create a store that starts with baseItems for a service layer described by algebra.

      // Describe the services parameters:
      var 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.
      var 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

      1. baseItems {Array}:

        An array of items that will populate the store.

      2. algebra {Algebra(compares)}:

        A description of the service layer's 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:
      var todoAlgebra = new set.Algebra({ ... });
      
      // Create a store with initial data.
      // Pass [] if you want it to be empty.
      var 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

      1. count {Number}:

        TODO describe

      2. makeItems {function}:

        A function that will generate baseItems

      3. algebra {Algebra(compares)}:

        A description of the service layer's parameters.

      Returns

      {Store()}:

      A store that can be used to simulate a restful service layer that supports filtering, pagination, and more.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.