forked from Softmotions/ejdb-csharp
-
Notifications
You must be signed in to change notification settings - Fork 3
Tutorial
Jury Soldatenkov edited this page Nov 22, 2013
·
4 revisions
The simplest way to do this is to use nuget package manager:
Install-Package Nejdb.Unofficial.
Package contains libraries built for .net40 and .net45. Earlier version are not supported.
-
First thing you need is to obtain an instance of nejdb.dll. Recommended way is to use static property
Library.Instance. It's safe to reuse across your application, but if there's a reason you need a separated instance ofLibrary- use static methodLibrary.Create(). Note: native library is exported toPath.GetTempFileName(). The file would be deleted whenLibrary.Dispose()called. -
Create an instance of EJDB database.
var database = Library.Instance.CreateDatabase();
Please note, it does not create or open database from disk, just object that can operate over database.
- Open (or create) database file using
//open database in default mode.
database.Open("foo.db");
//alternatively you can provide more options when open database.
database.Open(DbName, Database.DefaultOpenMode | OpenMode.TruncateOnOpen);
- Create collection to persist some document in.
var collection = dataBase.CreateCollection("BarCollection", CollectionOptions.None);