/// <summary> /// Creates a new edge /// </summary> /// <param name="document">The edge document</param> /// <param name="waitForSync">Define if the request should wait until synced to disk</param> /// <param name="baseResult"></param> /// <returns>DocumentIdentifierResult</returns> public async Task <IDocumentIdentifierResult> InsertAsync(string from, string to, object document, bool?waitForSync = null, Action <BaseResult> baseResult = null) { waitForSync = waitForSync ?? db.Setting.WaitForSync; var command = new HttpCommand(db) { Api = CommandApi.Graph, Method = HttpMethod.Post, Command = $"{graphName}/edge/{collection}", Query = new Dictionary <string, string>() }; var jObject = new DocumentSerializer(db).FromObject(document); jObject.Add("_from", JToken.FromObject(from)); jObject.Add("_to", JToken.FromObject(to)); command.Query.Add("waitForSync", waitForSync.ToString()); var result = await command.RequestMergedResult <InsertEdgeResult>(jObject).ConfigureAwait(false); if (!result.BaseResult.Error) { if (!db.Setting.DisableChangeTracking) { var container = db.ChangeTracker.TrackChanges(document, result.Result.Edge); if (container != null) { container.From = from; container.To = to; } } db.SharedSetting.IdentifierModifier.Modify(document, result.Result.Edge, from, to); } if (baseResult != null) { baseResult(result.BaseResult); } return(result.Result.Edge); }