Dot notation is available in 4.11 and later, with DQL_STRICT_MODE=false. Read more
When updating fields nested in a MAP, specify the field-value pairs you want to update.For MAP syntax, see Ditto Query Language > Types and Definitions > Map Operations.
Starting with SDK 4.8, you can use the deserialize_json() function in UPDATE statements to set fields from JSON-serialized strings. This is useful when you receive data as JSON strings (for example, from an API response) and want to update specific fields on existing documents.
You can also combine deserialize_json() with other SET assignments in the same UPDATE:
await ditto.store.execute( query: """ UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123' """, arguments: [ "colorJson": "\"red\"" ])
ditto.store.execute(""" UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123' """, mapOf("colorJson" to "\"red\""))
await ditto.store.execute(` UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123'`, { colorJson: '"red"' });
ditto.store.execute( "UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123'", Map.of("colorJson", "\"red\""));
var args = new Dictionary<string, string>();args.Add("colorJson", "\"red\"");await ditto.Store.ExecuteAsync( "UPDATE cars"+ " SET color = deserialize_json(:colorJson), mileage = 6000"+ " WHERE _id = '123'", args);
std::map<std::string, std::string> args;args["colorJson"] = "\"red\"";ditto.get_store().execute( "UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123'", args).get();
let query_result = ditto .store() .execute_v2(( "UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123'", serde_json::json!({ "colorJson": "\"red\"" }), )).await?;
await ditto.store.execute(""" UPDATE cars SET color = deserialize_json(:colorJson), mileage = 6000 WHERE _id = '123'""", arguments: {"colorJson": "\"red\""},);
In Ditto, fields need to be marked as โdeletedโ for other peers to know the field has been removed.
When unsetting a MAP, all children data types are iteratively unset.
Fields that are unset are ignored during subsequent DQL statements.
Calling UNSET on a large number of dynamically generated fields (for
example, dynamically created keys in a CRDT map) may cause performance to
degrade due to metadata accumulation over time. Benchmarks for this will
vary depending on your dataset size and query cardinality. You can
mitigate this accumulation by calling UNSET on a parent field
(or deleting the document itself).
UPDATE your_collection_nameUNSET field_name WHERE _id = '123'
-- Arrow (->) and tombstone() functions have been removed in v5 UPDATE your_collection_name SET your_field_name -> tombstone() WHERE _id = '123'