how to update only certain column/object in flutter objectbox?

  Kiến thức lập trình

I’m new to Flutter, how do I update certain objects/columns (not all columns)?

the table/entity class:

    @Entity()
    class Customer {
    int id;
    final String name;
    final String city;

    Customer ({this.id = 0, name= "", this.city = ""});
    }

let say…i want update
id=1,name=”john”,city=”New York”
to
id=1,name=”john”,city=”Tokyo”

the code:

    String strInput = ["1", "Tokyo"];
    List Lstr = (strInput).split(",");
    int idUpdate = int.tryParse(Lstr [0]) ?? 0;
    if (idUpdate > 0) {

                          customerBox.put(Customer(
                              id: idUpdate, city: Lstr [1]));
                      
                        }

the result = column ‘name’ filled with initial values :
id=1,name=””,city=”Tokyo”
thank you

New contributor

arif zein is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

0

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT