Skip to content

snissim/pogo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pogo

Pogo is an unofficial ORM for Google's Cloud Datastore (GCD). The API was inspired by the RavenDB client API.

Installation

Pogo is available on Nuget.

Setting up a GCD Dataset

You can follow Google's instructions here

Connection String

Pogo uses the standard config file connection strings:

<configuration>
    <connectionStrings>
        <add name="Pogo" connectionString="DatasetId = YOUR_DATASET_ID; CertificateFilePath = C:\Path\To\Your\Certificate\File-privatekey.p12; ServiceAccountId = your-service-account-email@developer.gserviceaccount.com; CertificatePassword = notasecret"/>
    </connectionStrings>
</configuration>

DatasetId: GCD Dataset ID (same as Google Cloud Project ID)

CertificateFilePath: Path to the private key file generated from step 10 here

ServiceAccountId: The service account from step 11 here

CertificatePassword: The password to the certificate (usually "notasecret")

Initialization

var datastore = new GoogleCloudDatastore("ConnStringName");

Writing Objects

Pogo takes your plain-old objects and converts them to the Google Datastore format. Your object must have a key property named "Id" (not case sensitive).

var person = new TestPerson
{
    Id = "TestPersons/99",
    FirstName = "Rey",
    HireDate = new DateTime(2012, 5, 7, 9, 30, 0),
    HourlyRate = 25.0,
    IsActive = true
};

using (var session = datastore.OpenSession())
{
    session.Store(person);
    session.SaveChanges();
}

Retrieving Objects by ID

using (var session = datastore.OpenSession())
{
    var person = session.Load<TestPerson>("TestPersons/99");
}

Sessions

All interactions with GCD happen within the context of a session. Pogo implements the Unit of Work pattern. If an object is retrieved within a session, modified, and SaveChanges is called, then those changes will be applied to the datastore.

Querying

GCD supports comparison operators (equal, less than, greater than, less than or equal, greater than or equal). Pogo supports LINQ and translates these queries into low-level GCD queries.

using (var session = datastore.OpenSession())
{
    var results = session.Query<TestPerson>()
        .Where(t => t.HourlyRate > 50.0)
        .ToList();
}

Indexes

All GCD queries use indexes. For basic queries, indexes are auto-generated. If inequality filters are applied to multiple properties, you need to explicitly create an index.

If GCD doesn't support auto-indexing for complex queries soon, then we will add index generation to Pogo. For now, you need to create manual indexes and publish them to GCD using the gcd tool.

Contributing

See the CONTRIBUTING document.

About

Pogo is written and maintained by Samuel Nissim.

License

Pogo is free software, and may be redistributed under the terms specified in the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages