ra0o0f / arangoclient.net

ArangoDB .NET Client with LINQ support
Apache License 2.0
99 stars 37 forks source link

Can't have Upsert working #97

Open jrouaix opened 6 years ago

jrouaix commented 6 years ago

Hello, i'm really sorry to bother, but after a few hours struggling, I can't have a simple upsert working. image

The update part is working when documents are already created but if not, nothing is inserted.

Any idea ? Is this a bug or there is something I didn't do well ?

ra0o0f commented 6 years ago

@jrouaix the problem is you are trying to iterate on Test collection and do upsert, obviously when there is no document exists it insert nothing, your query should be like this:

                // do not iterate here  => db.Query<TEST>()
                db.Query()
                .Upsert(_ => new Test { _key = name },
                    _ => new Test { _key = name },
                    (_, old) => new { updated = AQL.DateNow() })
                    // and specify collection
                    .In<Test>()
                    .Execute();

and please read this answer for more understanding how upsert works: https://stackoverflow.com/questions/39502158/arangodb-net-upsert-always-insert/39543181#39543181

jrouaix commented 6 years ago

It's working ! thank you very much ! Do you plan to have an ExecuteAsync() method in the next release ?