DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
      • behaviors
        • ./base/
        • ./cache-requests/
        • ./can/map/
        • ./can/ref/
        • ./constructor/callbacks-once/
        • ./constructor/
        • ./constructor/store/
        • ./data/callbacks/
        • ./data/callbacks-cache/
        • ./data/combine-requests/
        • ./data/localstorage-cache/
        • ./data/memory-cache/
        • ./data/parse/
        • ./data/url/
        • ./data/worker/
        • ./fall-through-cache/
        • ./real-time/
      • modules
        • ./can/base-map/
        • ./can/model/
        • ./can/super-map/
        • ./can/tag/
        • ./helpers/weak-reference-map
      • data types
        • DataInterface
          • clear
          • createData
          • destroyData
          • getData
          • getListData
          • getSets
          • updateData
          • updateListData
        • Instance
        • InstanceInterface
        • List
        • ListData
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-connect
  • /
  • DataInterface
  • / On this page
    • DataInterface

      typedef

      The most common raw data methods.

      • source

      DataInterface

      The DataInterface methods are the methods most used most commonly by can-connect behaviors to get or mutate information in some form of persisted storage. The DataInterface methods only operate on raw data comprised of plain JavaScript Objects, Arrays and primitive types.
      This is in contrast to the InstanceInterface methods that operate on typed data.

      Those methods are:

      • clear - Remove all records.
      • createData - Create a new record.
      • destroyData - Destroy a record.
      • getData - Get a single record.
      • getListData - Get multiple records.
      • getSets - Get the Sets available within the persisted storage.
      • updateData - Update a single record.
      • updateListData - Update multiple records.

      Behaviors either implement these methods or overwrite these methods to perform some extra functionality.

      For example, can-connect/data/url/url implements these behaviors to make an Ajax request like:

      connect.behavior("data/url", function(baseConnection) {
          return {
              getListData: function(set){
                  return ajax({
                      type: "GET",
                      url: this.url,
                      data: set
                  });
              },
              getData: function(){ ... },
              ...
          }
      });
      

      The can-connect/data/parse/parse overwrites the baseConnection connection's methods to perform cleanup on the response data:

      connect.behavior("data/parse", function(baseConnection) {
          return {
              getListData: function(set){
                  var self = this;
                  return baseConnection.getListData(set).then(function(response){
                      return self.parseListData(response);
                  });
              },
              getData: function(){ ... },
              ...
          }
      });
      

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