yojimbo87 / ArangoDB-NET

C#/.NET/Mono driver for ArangoDB
MIT License
107 stars 66 forks source link

CreateEdge does not return _from and _to #33

Closed chefhl closed 8 years ago

chefhl commented 8 years ago

Hello,

while prototyping ArangoDB-NET I noticed that the CreateEdge method of ADocument does not return the content of the "_from" and "_to" fields in its result structure just "_id", "_key" and "_rev". So to get this information right after creation I would have to explicitly query for that edge document by id.

Not a major issue but if I want to consistently return the populated document after creation it is a bit annoying and a little less performant.

Best regards Patrick

yojimbo87 commented 8 years ago

Hi Patrick,

this is standard behaviour which mirrors ArangoDB 3.x HTTP API when creating a new edge (same pattern when creating new document - only _id, _key and _rev fields are returned), however if you call ReturnNew method before CreateEdge then resulting document would contain new field where you can find entire document data, e.g.

var createResult = db
    .Document
    .ReturnNew()
    .CreateEdge("MyEdgeCol", "MyDocCol/123", "MyDocCol/456");

// createResult.Value.ID() == createResult.Value.String("new._id")
// createResult.Value.Key() == createResult.Value.String("new._key")
// createResult.Value.Rev() == createResult.Value.String("new._rev")
// "MyDocCol/123" == createResult.Value.String("new._from")
// "MyDocCol/456" == createResult.Value.String("new._to")

Hope it helps.

chefhl commented 8 years ago

Thanks works pretty well!