public async Task Test() { const string spaceName = "primary_only_index"; using (var tarantoolClient = await Client.Box.Connect(ConnectionStringFactory.GetReplicationSource_1_7())) { var schema = tarantoolClient.GetSchema(); var space = schema[spaceName]; try { await space.Insert((2u, "Music", 0.0f)); } catch (ArgumentException) { await space.Delete <ValueTuple <uint>, ValueTuple <uint, string, double> >(ValueTuple.Create(2u)); await space.Insert((2u, "Music", 0.0f)); } await space.Select <ValueTuple <uint>, ValueTuple <uint, string, double> >(ValueTuple.Create(2u)); await space.Replace((2u, "Car", -24.5)); await space.Update <ValueTuple <uint>, ValueTuple <uint, string, double> >( ValueTuple.Create(2u), new UpdateOperation[] { UpdateOperation.CreateAddition(1, 2) }); await space.Upsert( (5u, "Test", 20), new UpdateOperation[] { UpdateOperation.CreateAssign(1, 1) }); } }
static async Task DoWork() { using (var box = await Box.Connect( "operator:123123@localhost:3301")) { var schema = box.GetSchema(); var space = await schema.GetSpace("users"); var primaryIndex = await space.GetIndex("primary_id"); //await space.Insert(TarantoolTuple.Create(Guid.NewGuid().ToString(), //"Vladimir Vladimirov", "vvladimirov", "*****@*****.**", 10L)); var updatedData = await space.Update <TarantoolTuple <string>, TarantoolTuple <string, string, string, string, long> >( TarantoolTuple.Create("600ca93b-10dc-4ebe-8c78-95f4d5384426"), new UpdateOperation[] { UpdateOperation.CreateAssign(4, 47L) }); var data = await primaryIndex.Select <TarantoolTuple <string>, TarantoolTuple <string, string, string, string, long> >( TarantoolTuple.Create(String.Empty), new SelectOptions { Iterator = Iterator.All }); var loginIndex = await space.GetIndex("secondary_login"); var users = await loginIndex.Select <TarantoolTuple <string>, TarantoolTuple <string, string, string, string, long> >( TarantoolTuple.Create("petrov")); var petrov = users.Data; var ratingIndex = await space.GetIndex("secondary_rating"); var ratingUsers = await ratingIndex.Select <TarantoolTuple <long>, TarantoolTuple <string, string, string, string, long> >( TarantoolTuple.Create(15L), new SelectOptions { Iterator = Iterator.Ge }); await box.Call("update_rating"); foreach (var item in data.Data) { Console.WriteLine(item); } } }
public async Task HashIndexMethods() { const string spaceName = "primary_only_index"; await ClearDataAsync(spaceName); using (var tarantoolClient = await Client.Box.Connect(ConnectionStringFactory.GetReplicationSource_1_7())) { var index = tarantoolClient.GetSchema()[spaceName]["primary"]; try { await index.Insert((2, "Music", 0.0)); } catch (ArgumentException) { await index.Delete <ValueTuple <int>, ValueTuple <int, string, double> >(ValueTuple.Create(2)); await index.Insert((2, "Music", 0.0)); } await index.Select <ValueTuple <uint>, ValueTuple <int, string> >(ValueTuple.Create(1029u)); await index.Replace((2, "Car", -245.3)); await index.Update <ValueTuple <int, string, double>, ValueTuple <int> >( ValueTuple.Create(2), new UpdateOperation[] { UpdateOperation.CreateAddition(100, 2) }); await index.Upsert((6u, "name", 100.0), new UpdateOperation[] { UpdateOperation.CreateAssign(2, 2) }); await index.Upsert((6u, "name", 100.0), new UpdateOperation[] { UpdateOperation.CreateAddition(-2, 2) }); var result = await index.Select <ValueTuple <uint>, ValueTuple <uint, string, double> >(ValueTuple.Create(6u)); result.Data[0].Item1.ShouldBe(6u); } }