First Code Release
The initial code has been released on bitbucket here. Enjoy…below are some simple instructions on getting started.
1. You must already have a SQL server database to put your collection data into.
2. Start with the console and the process projects. Compile them both, then edit the .config file for the process project with the connection string to your SQL database.
3. Start the process in a cmd window.
4. Start your console project and connect to your instance (using the default).
5. Start creating your collections using the console app or the c# driver from your own application.
—
Using the Console Application
The console application is similar to the command line console for MongoDB. You submit JSON-formatted requests and the server responds. Here is a cheat sheet for some of the most common commands. This application is not complete yet, so there is a lot more to come.
* getting the current server config
{ action: "driver.showConfig" }
* creating a new document domain (logical group of collections)
{ action: "domain/create", request: { "DomainId" : "MyApplicationName" } }
* creating a new collection in that domain
{ action: "collection/create", request: { "DomainId" : "MyApplicationName", "CollectionName" : "Person" }}
* creating/updating a document in that collection
{ action: "update", domain: "MyApplicationName", collection: "Person" data: { "_id": CSUUID("C11F3370-D813-4142-A878-2BBD4DABDC0A"), FirstName: "Michael" , LastName: "Scott", CompanyName: "Dundler-Mifflin", Type: 1 } }
* lookup a specific document by id
{ action: "lookup", domain: "MyApplicationName", collection: "Person", id: "C11F3370-D813-4142-A878-2BBD4DABDC0A" }
* delete a specific document by id
{ action: "delete", domain: "MyApplicationName", collection: "Person", id: "C11F3370-D813-4142-A878-2BBD4DABDC0A" }
Using the C# Driver
* making your server connection - using the default (thread safe)
BsonSqlServer server = BsonSqlServer.Connect("http://127.0.0.1:1972");
* getting a pointer to (or creating) your domain (thread safe)
BsonSqlDomain domain = server.GetDomain("MyApplicationName");
* getting a pointer to (or creating) your collection (thread safe)
BsonSqlCollection people = domain.GetCollection("Person");
* making sure you have an index to search by last name
BsonSqlCollection people = domain.GetCollection("Person"); people.EnsureIndex("PersonLastNameSearchIndex", false, false, new IndexKey[] { new IndexKey() { FieldName = "LastName", DataType = BsonType.String, Length=100, UserVarChar = true }});
* looking up a person by id (as a BsonDocument) - only bound queries are threadsafe
BsonDocument person = people.FindOneByIdAs(id);
* looking up a person by id (as a POCO) - only bound queries are threadsafe
Person person = people.FindOneByIdAs(id);
* create a new person
Person p = new Person() { FirstName = "Michael", LastName = "Scott", CompanyName = "DundlerMifflin" }; people.Insert(p);