private async ValueTask AddToParentsChildrenCollection(NodeID parentPath, NodeID requested, FileTypes.Ft fileType, IDatabaseSession db) { var parentDir = await db.Read(parentPath); var alreadyPresent = parentDir?.Attributes.Items .FirstOrDefault(kv => kv.Key.Equals(Attr.Children)) ?.Value.Map?.Items?.Any(x => x.Key.Equals(requested)) ?? false; if (!alreadyPresent) { var dataToAdd = new Node { Id = parentPath, Attributes = new Map { Items = new List <KeyValue>() { Utils.Prop(DateTime.UtcNow.Ticks, Attr.Children, new Map { Items = new List <KeyValue>() { Utils.Prop(DateTime.UtcNow.Ticks, requested, FileTypes.FromFt(fileType)) } }) } } }; if (parentDir == null) { dataToAdd.Attributes.Items.Add( Utils.Prop(DateTime.UtcNow.Ticks, Attr.Type, FileTypes.TypeFolder ) ); } // Merge these new fields into the existing node. await db.Merge(dataToAdd); } }