putMeta method
Updates the metadata of AtKey.key
if it is already present. Otherwise creates a new key without a value.
By default namespace that is used to create the AtClient instance will be appended to the key. phone@alice will be saved as
phone.persona@alice where 'persona' is the namespace. If you want to save by ignoring the namespace set AtKey.metadata.namespaceAware
to false.
update:meta:phone@alice:ttl:60000
var metaData = Metadata()..ttl = 60000
var key = AtKey()..key='phone'
..metadata=metaData
putMeta(key);
update:meta:phone@alice:ttr:120000:ccd:true
var metaData = Metadata()..ttr = '120000'
..ccd = true
var key = AtKey()..key='phone'
..metadata=metaData
putMeta(key);
If you want to set both value and metadata please use put
Implementation
@override
Future<bool> putMeta(AtKey atKey) async {
var updateKey = atKey.key;
var metadata = atKey.metadata!;
if (metadata.namespaceAware) {
updateKey = _getKeyWithNamespace(atKey.key!);
}
var sharedWith = atKey.sharedWith;
var builder = UpdateVerbBuilder();
builder
..atKey = updateKey
..sharedBy = currentAtSign
..sharedWith = sharedWith
..ttl = metadata.ttl
..ttb = metadata.ttb
..ttr = metadata.ttr
..ccd = metadata.ccd
..isBinary = metadata.isBinary
..isEncrypted = metadata.isEncrypted
..dataSignature = metadata.dataSignature
..operation = UPDATE_META;
var isSyncRequired = true;
if (SyncUtil.shouldSkipSync(updateKey!)) {
isSyncRequired = false;
}
var updateMetaResult =
await getSecondary().executeVerb(builder, sync: isSyncRequired);
return updateMetaResult != null;
}