Actualizar item o campo en Wix base de datos

Actualizar item o campo en Wix base de datos

https://www.wix.com/corvid/forum/community-discussion/update-an-existing-row-in-db-in-new-data



the you update the fields you need and continue according to the example here:

http://www.wix.com/code/reference/wix-data.html#update 


please note in the update documentation the following section:
If an item in the collection has that _idvalue, update replaced the item's property values with the ones in the specified item. If the existing item had properties with values and those properties were not included in the supplied item, the values in those properties are lost. The item's _updatedDate property is also updated to the current date.
so you will need to copy all the fields from the item you read in your db, just like you do with the _id, you need to do the same with all the rest of the fields
let toUpdate = {
 "_id": exists.items[0]._id ,
 "email" : emailSession,
 "wixTemplate": wixDesign
 };





Here's a very simple example of "Shlomi's way" - get() a record, make a change, and then update():
wixData.get("Stuff", <record id>)
.then((toUpdate) => {
   toUpdate.fld = "x";
   wixData.update("Stuff", toUpdate)
   .then((result) => {
      // updated object returned so let's take a look
      console.log(result);
   })
   .catch((err) => {
      let errorMsg = err;
   });
})
.catch((err) => {
   let errorMsg = err;
});
I hope this helps.
Yisrael


SHARE

Oscar perez

Arquitecto especialista en gestion de proyectos si necesitas desarrollar algun proyecto en Bogota contactame en el 3006825874 o visita mi pagina en www.arquitectobogota.tk

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comentarios:

Publicar un comentario