-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How LiteDB Works
Mauricio David edited this page Mar 14, 2015
·
17 revisions
- database structures overview (pages, services)
- Document Growth
- file format
- database info
- transactions
- herança LiteDatabase
- user versions
- concurrence
- avoid dirty read
- concurrent read/write
- lock database / transaction
- windows locks - 250ms
- journaling
- recovery
- on open database
- journal file
- limit and sizes (page-size, index-per-collection, document-size)
- connection string
- thread safe?
LiteDB architeture is ideal to work in repository pattern data access. You can write a class that inheriths LiteDatabase
and add your collections as properties:
public class MyDB : LiteDatabase
{
public MyDB()
: this (@"C:\Temp\mydatabase.db")
{
}
private LiteCollection<Customer> _customers;
public LiteCollection<Customer> Customers
{
get { return _customers ?? (_customers = this.GetCollection<Customer>("customers")); }
}
private LiteCollection<Order> _orders;
public LiteCollection<Order> Orders
{
get { return _orders ?? (_orders = this.GetCollection<Order>("orders")); }
}
}
// later...
using(var db = new MyDB())
{
var cust = new Customer { Id = 123, Name = "John Doe" };
db.Customers.Insert(cust);
db.Customers.Delete(123);
}
Data Modeling
- Data Structure
- BsonDocument
- Object Mapping
- Relationships with Document References
- Collections
- FileStorage
Index
Query
Database
Version 4 changes
Shell