Skip to content

Database | Connect

meow12 edited this page Dec 12, 2019 · 1 revision

When you enable a database service in your CodeMash dashboard page we create a new MongoDb database for you. After that is done you are able to create collections using our provided tools in the dashboard. After you create a collection you can start adding records through the dashboard or using provided SDK.

1.1. Create a Client

For database and all other services you need to create a client to be able to send requests to our servers.

var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";

var client = new CodeMashClient(apiKey, projectId);

1.2. Initialize database service

After you have created the client you can initialize database service.

var service = new CodeMashRepository<Person>(client);

Here Person is a class which extends interface IEntity. More about it in 1.3. section.

1.3. Entities

All your collection classes must extend IEntity interface to be able to use database service.

[CollectionName("sdk_test")]
public class Person : Entity
{
    public string Name { get; set; }
}

Entity - class implementing IEntity interface.
CollectionName - attribute which tells the name of the collection.



  1. Getting Started
    1.1. Register at CodeMash
    1.2. Install CodeMash
    1.3. Set up API keys

  2. Microservices
    2.1. Database
       2.1.1. Connect
       2.1.2. Insert
    2.2. Membership
       2.2.1. Connect
       2.2.2. User Registration
       2.2.3. Authentication
       2.2.4. User Management
    2.3. Files Service
       2.2.1. Connect
    2.4. Email Notifications
       2.2.1. Connect
       2.2.1. Emails
    2.5. Push Notifications
       2.2.1. Connect
       2.2.1. Devices
       2.2.1. Notifications
       2.2.1. Templates
    2.6. Scheduler
    2.7. Code Service
       2.2.1. Connect
       2.2.2. Functions
    2.8. Logs
       2.2.1. Connect
       2.2.2. Logs Management

  3. Other Services
    3.1. Project Settings
    3.2. Tokens Binding

Clone this wiki locally