private void PrepareDb(EJDB2 db) { db.Put("c1", TestUtils.Json); db.Delete("c1", 1); db.Put("mycoll", @"{""foo"":""bar""}"); db.Put("mycoll", @"{""foo"":""baz""}"); db.EnsureStringIndex("mycoll", "/foo", true); db.Patch("mycoll", TestUtils.Patch, 2); }
public void OnlineBackup_Test2() { using var db = CreateTestDb(); db.Put("cc1", "{\"foo\": 1}"); db.RenameCollection("cc1", "cc2"); db.OnlineBackup("test-bkp.db"); var options2 = new EJDB2OptionsBuilder("test-bkp.db") .WithWAL() .GetOptions(); using var db2 = new EJDB2(options2); string val = db2["cc2", 1]; Assert.Equal("{\"foo\":1}", val); }
static async Task Main(string[] args) { if (File.Exists("example.db")) { File.Delete("example.db"); } var options = new EJDB2OptionsBuilder("example.db") .WithWAL().Truncate() .GetOptions(); using var db = new EJDB2(options); long id = db.Put("parrots", "{\"name\":\"Bianca\", \"age\": 4}"); Console.WriteLine("Bianca record: {0}", id); id = db.Put("parrots", "{\"name\":\"Darko\", \"age\": 8}"); Console.WriteLine("Darko record: {0}", id); id = db.Put("parrots", "{\"name\":\"тест 迶逅透進\", \"age\": 8}"); Console.WriteLine("UTF8 test record: {0}", id); string data = db.Get("parrots", id); Console.WriteLine("Record {0} data: {1}", id, data); string info = db.GetInfo(); Console.WriteLine("DB info: {0}", info); db.CreateQuery("@parrots/[age > :age]").SetLong("age", 3) .Execute((docId, doc) => { Console.WriteLine("Found {0}: {1}", docId, doc); return(1); }); var query = db.CreateQuery("@parrots/[age > :age]").SetLong("age", 3); await foreach (var(docId, doc) in query.ToAsyncEnumerable()) { Console.WriteLine("Found {0}: {1}", docId, doc); } }