-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Shell
LiteDB project has a simple console application that can be used to work with your databases with an application. It's very useful to see, update and test your data. Shell application support all database commands in a similar MongoDB shell syntax.
Shell commands are available in LiteDatabase too. You can execute any command:
using(var db = new LiteDatabase("MyDatabase.db"))
{
db.Run("db.customer.insert { _id:1, Name: \"John Doe\" }");
var col = db.GetCollection("customer");
var john = col.FindById(1);
}The commands here works only in console application LiteDB.Shell.exe:
-
help [full]- Display basic or full commands help -
open [filename]- Open new database. If not exists, create a new one -
close- Close current database -
pretty- Show JSON in pretty format -
ed- Open notepad.exe with last command to edit -
run [filename]- Read filename as interpret each line as a new command -
spool [on|off]- Turn on/off spool of all commands -
timer- Show a timer on command prompt -
--- Comment line - ignored line -
/[command]/- Supports multiline command -
quit- Exit shell application
Syntax: db.<collection>.<command>
-
insert [JsonDoc]- Find a document using query filter syntaxdb.customer.insert { _id:1, Name: "John Doe", Age: 38 }-
db.customer.insert { Name: "John Doe" }- Auto create Id asObjectId
-
find- Find a document using query filter syntaxdb.customer.find Name = "John Doe"db.customer.find Name LIKE "John" and Age > 30
-
begin- Begin a new transaction -
commit- Commit current transaction -
rollback- Rollback current transaction -
shell in database class
-
command references
-
run shell in db.Shell("command")
Data Modeling
- Data Structure
- BsonDocument
- Object Mapping
- Relationships with Document References
- Collections
- FileStorage
Index
Query
Database
Version 4 changes
Shell