Skip to content

Introduction

The Cobra Database package is a necessary dependency for several of our assets, delivering the required services for these assets to operate smoothly. It also offers an opportunity for users to familiarize themselves with setting up our Docker services before committing to any of our other assets that depend on this package.

Additionally, this package is a valuable resource for anyone interested in exploring Docker and containerization technologies.

Features

  • Support for Custom Data Types: Manage simple custom data types in your Unity projects.
  • REST API and Unity Client: Comes with a REST API for data management and a Unity C# scripts for interacting with the API.
  • Security: Enhanced protection is provided for all REST API endpoints via an automatically generated secret, ensuring a straightforward setup process. This secret is securely stored on your server, safeguarding your data.
  • Rate Limits: All server endpoints are rate limited to prevent abuse.
  • Automatic Backups: The package features automatic backup functionalities.
  • Automatic Restarts: In case of any disruptions, such as connectivitiy issues, the services are designed to continuously restart.

Core Components

REST API

The REST API, built with ASP.NET, provides endpoints for managing custom data:

  • Set Data: Allows you to add or update data associated with a unique (string) key. Conceptually, each data type functions like a table, with the key serving as the table's name.
  • Get Data: Retrieves data based on a given key.
  • Delete Data: Removes data associated with a specific key.
  • Get All Keys: Lists all the keys for the custom data stored.

Easy To Use

The package comes with C# scripts that can easily interact with the REST API to manage data from within Unity projects. It offers methods for setting, getting, and deleting data, as well as retrieving all keys.

For example, to create or update data you simply call a method:

await DataService.Api.SetDataAsync<SampleData>(data);

To read data you also just call one method with or without a key (defaults to the type name):

SampleData savedData = await DataService.Api.GetDataAsync<SampleData>("MyKey");

It's also possible to get a list of all the keys:

List<string> allKeys = await DataService.Api.GetKeysAsync();

Secure

The REST API uses middleware to protect endpoints, requiring a secret key for access. This approach ensures that only authorized users can manage data, protecting your application from unauthorized access.