public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var docs = col.GetIndexes(); return new BsonArray(docs); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var query = this.ReadQuery(s); return col.Delete(query); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var newName = s.Scan(@"[\w-]+"); return db.RenameCollection(col.Name, newName); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var doc = JsonSerializer.Deserialize(s).AsDocument; return col.Update(doc); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var id = this.ReadId(s); var metadata = JsonSerializer.Deserialize(s).AsDocument; return db.FileStorage.SetMetadata(id, metadata); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var index = s.Scan(this.FieldPattern).Trim(); return col.DropIndex(index); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var cols = db.GetCollectionNames().OrderBy(x => x).ToArray(); if (cols.Length == 0) return BsonValue.Null; return string.Join(Environment.NewLine, cols); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var query = this.ReadQuery(s); var skipLimit = this.ReadSkipLimit(s); var docs = col.Find(query, skipLimit.Key, skipLimit.Value); return new BsonArray(docs); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var filename = s.Scan(@".*"); using (var sr = new StreamReader(filename, Encoding.UTF8)) { var docs = JsonSerializer.DeserializeArray(sr); return col.InsertBulk(docs.Select(x => x.AsDocument)); } }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var value = JsonSerializer.Deserialize(s); if (value.IsArray) { return col.Insert(value.AsArray.RawValue.Select(x => x.AsDocument)); } else { col.Insert(new BsonDocument(value.AsDocument)); return BsonValue.Null; } }
public BsonValue Execute(LiteDatabase db, StringScanner s) { if (s.HasTerminated) { var files = db.FileStorage.FindAll().Select(x => x.AsDocument); return new BsonArray(files); } else { var id = this.ReadId(s); var files = db.FileStorage.Find(id).Select(x => x.AsDocument); return new BsonArray(files); } }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var id = this.ReadId(s); var filename = s.Scan(@"\s*.*").Trim(); var file = db.FileStorage.FindById(id); if (file != null) { file.SaveAs(filename, true); return file.AsDocument; } else { return false; } }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var result = new StringBuilder(); if (s.HasTerminated || s.Match("mem$")) { var mem = s.Match("mem$"); result = DumpDatabase.Pages(db, mem); } else { var col = s.Scan(@"[\w-]+"); var field = s.Scan(@"\s+\w+").Trim(); result = DumpDatabase.Index(db, col, field); } return result.ToString(); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); var field = s.Scan(this.FieldPattern).Trim(); var doc = JsonSerializer.Deserialize(s); if (doc.IsNull) { return col.EnsureIndex(field, false); } else if (doc.IsBoolean) { return col.EnsureIndex(field, doc.AsBoolean); } else { var options = db.Mapper.ToObject<IndexOptions>(doc.AsDocument); return col.EnsureIndex(field, options); } }
public BsonValue Execute(LiteDatabase db, StringScanner s) { return db.GetDatabaseInfo(); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var col = this.ReadCollection(db, s); return col.Drop(); }
public BsonValue Execute(LiteDatabase db, StringScanner s) { db.Rollback(); return BsonValue.Null; }
public BsonValue Execute(LiteDatabase db, StringScanner s) { db.Commit(); return BsonValue.Null; }
public BsonValue Execute(LiteDatabase db, StringScanner s) { db.BeginTrans(); return BsonValue.Null; }
public BsonValue Execute(LiteDatabase db, StringScanner s) { var id = this.ReadId(s); return db.FileStorage.Delete(id); }