values property

InstanceType values
read / write

Values to be sent to database during an update or insert query.

You set values for the properties of this object to insert a row or update one or more rows. This property is the same type as the type being inserted or updated. values is empty (but not null) when a Query is first created, therefore, you do not have to assign an instance to it and may set values for its properties immediately:

    var q = Query<User>() = 'Joe'
      ..values.job = 'programmer';
    await q.insert();

You may only set values for properties that are backed by a column. This includes most properties, except all ManagedSet properties and ManagedObject properties that do not have a Relate annotation. If you attempt to set a property that isn't allowed on values, an error is thrown.

If a property of values is a ManagedObject with a Relate annotation, you may provide a value for its primary key property. This value will be stored in the foreign key column that backs the property. You may set properties of this type immediately, without having to create an instance of the related type:

    // Assumes that Employee is declared with the following property:
    // @Relate(#employees)
    // Manager manager;

    final q = Query<Employee>() = "Sally" = 10;
    await q.insert();

WARNING: You may replace this property with a new instance of InstanceType. When doing so, a copy of the object is created and assigned to this property.

    final o = SomeObject() = 1;
    final q = Query<SomeObject>()
      ..values = o; = 2;
    assert( == 1); // true


InstanceType values