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
  • /
  • updateData
  • / On this page
    • updateData

      typedef

      Updates a record in the collection.

      • source

      function(instanceData)

      Updates a record given the serialized form of the data. Returns a promise that resolves to a object that contains the new properties and values of the record.

      An example request and response might look like:

      connection.updateData({
          id: 5,
          name: "do dishes",
          createdAt: 1477104548997
      }).then(function(instanceData){
          instanceData //-> {
          //  id: 5,
          //  name: "do dishes",
          //  createdAt: 1477104540000,
          //  updatedAt: 1477104580000
          //}
      })
      

      The following shows how can-connect/constructor/constructor calls updateData and what it does with the response:

      // get its raw data
      var instanceData = connection.serializeInstance(myInstance);
      
      connection.updateData(instanceData).then(function(updatedInstanceData){
        connection.updatedInstance(myInstance, updatedInstanceData);
      })
      

      Parameters

      1. instanceData {Object}:

        The serialized data of the instance.

      Returns

      {Promise<Object>}:

      A promise resolved with the updated data of the newly created instance.

      By default, updatedInstance deletes properties in myInstance that are not in updatedInstanceData. To change that behavior, overwrite updatedInstance.

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