Official C# / .NET client for the ONQL database server.
dotnet add package onql-clientOr in a .csproj:
<PackageReferenceInclude="onql-client"Version="0.1.0" />git clone https://github.com/ONQL/onqlclient-csharp.git
dotnet add reference ./onqlclient-csharp/ONQL.Client.csprojusingONQL;varclient=awaitONQLClient.CreateAsync("localhost",5656);awaitclient.InsertAsync("mydb","users","{\"id\":\"u1\",\"name\":\"John\",\"age\":30}");stringrows=awaitclient.OnqlAsync("mydb.users[age>18]");Console.WriteLine(rows);awaitclient.UpdateAsync("mydb","users","{\"age\":31}",client.Build("mydb.users[id=$1].id","u1"));awaitclient.DeleteAsync("mydb","users","","default","[\"u1\"]");awaitclient.CloseAsync();Creates and returns a connected client instance.
Sends a raw request frame and waits for a response.
Closes the connection.
On top of raw SendRequestAsync, the client exposes convenience methods for
the Insert / Update / Delete / Onql operations. Each one builds the
standard payload envelope for you and parses the {error, data} envelope —
throwing InvalidOperationException on a non-empty error, returning the
raw data substring on success.
Because the driver is dependency-free, every JSON-valued parameter is passed
as a pre-serialized JSON string. Use System.Text.Json, Newtonsoft.Json,
or any library you like to serialize.
db is passed explicitly to Insert / Update / Delete. Onql takes a
fully-qualified ONQL expression.
query arguments are ONQL expression strings, e.g.
mydb.users[id="u1"].id.
Insert a single record.
awaitclient.InsertAsync("mydb","users","{\"id\":\"u1\",\"name\":\"John\",\"age\":30}");await client.UpdateAsync(db, table, recordJson, query) / client.UpdateAsync(db, table, recordJson, query, protopass, idsJson)
Update records matching query (or idsJson). Pass "" for query when
using idsJson.
awaitclient.UpdateAsync("mydb","users","{\"age\":31}",client.Build("mydb.users[id=$1].id","u1"));awaitclient.UpdateAsync("mydb","users","{\"active\":false}","","default","[\"u1\"]");await client.DeleteAsync(db, table, query) / client.DeleteAsync(db, table, query, protopass, idsJson)
Delete records matching query (or idsJson).
awaitclient.DeleteAsync("mydb","users",client.Build("mydb.users[id=$1].id","u1"));awaitclient.DeleteAsync("mydb","users","","default","[\"u1\"]");Run a raw ONQL query.
stringdata=awaitclient.OnqlAsync("mydb.users[age>18]");Replace $1, $2, … placeholders with values.
stringq=client.Build("mydb.users[name=$1 and age>$2]","John",18);stringdata=awaitclient.OnqlAsync(q);Static helper that parses the {error, data} envelope.
<request_id>\x1E<keyword>\x1E<payload>\x04
\x1E— field delimiter\x04— end-of-message marker
MIT