Skip to content

Repository Operations

Repositories provide typed entity storage with schema validation.


Creates a new entity in the repository.

Request:

{
"data": {
"name": "Acme Corp",
"industry": "Technology",
"employeeCount": 500
}
}

Response (201 Created):

{
"id": "ent_abc123",
"data": {
"name": "Acme Corp",
"industry": "Technology",
"employeeCount": 500
},
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}

Lists all entities with pagination.

Query Parameters:

ParameterTypeDefaultDescription
limitinteger20Max items to return
cursorstringnullPagination cursor

Response (200 OK):

{
"entities": [
{
"id": "ent_abc123",
"data": { "name": "Acme Corp" },
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
],
"nextCursor": "eyJsYXN0S2V5Ijo...",
"totalCount": 150
}

GET /api/v1/repositories/{repositoryId}/{entityId}

Section titled “GET /api/v1/repositories/{repositoryId}/{entityId}”

Gets an entity by ID.

Response (200 OK):

{
"id": "ent_abc123",
"data": {
"name": "Acme Corp",
"industry": "Technology"
},
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}

PUT /api/v1/repositories/{repositoryId}/{entityId}

Section titled “PUT /api/v1/repositories/{repositoryId}/{entityId}”

Updates an existing entity.

Request:

{
"data": {
"name": "Acme Corporation",
"industry": "Technology",
"employeeCount": 600
}
}

Response (200 OK): Returns updated entity.


DELETE /api/v1/repositories/{repositoryId}/{entityId}

Section titled “DELETE /api/v1/repositories/{repositoryId}/{entityId}”

Deletes an entity.

Response (204 No Content): Empty body on success.


POST /api/v1/repositories/{repositoryId}/query

Section titled “POST /api/v1/repositories/{repositoryId}/query”

Queries entities with optional filtering.

Request:

{
"filter": "industry = :industry",
"filterValues": {
":industry": "Technology"
},
"limit": 20,
"cursor": null,
"sortBy": "createdAt",
"sortOrder": "desc"
}

Response (200 OK): Same as list entities response.


// Define entity
public record Customer : EntityBase
{
public required string Name { get; init; }
public required string Email { get; init; }
public string? Phone { get; init; }
public CustomerTier Tier { get; init; } = CustomerTier.Standard;
}
public enum CustomerTier
{
Standard,
Premium,
Enterprise
}
// Get repository reference
var customers = client.GetRepository<Customer>("repo_customers");
// Create entity
var customer = new Customer
{
Id = Guid.NewGuid().ToString(),
Name = "Acme Corp",
Email = "contact@acme.com",
Tier = CustomerTier.Premium
};
var createResult = await customers.CreateAsync(customer);
// Get entity
var getResult = await customers.GetAsync(customer.Id);
// Update entity
var updatedCustomer = customer with { Tier = CustomerTier.Enterprise };
var updateResult = await customers.UpdateAsync(updatedCustomer);
// Delete entity
var deleteResult = await customers.DeleteAsync(customer.Id);
// List entities
var listResult = await customers.ListAsync(new PaginationOptions { Limit = 50 });
// Query entities
var filter = new QueryFilter { PartitionKey = customer.Id };
var queryResult = await customers.QueryAsync(filter);
// Check existence
var existsResult = await customers.ExistsAsync(customer.Id);
if (existsResult.IsSuccess && existsResult.Value)
{
Console.WriteLine("Customer exists");
}

When using the C# SDK, entities should extend EntityBase:

public abstract record EntityBase : IEntity
{
public required string Id { get; init; }
public DateTimeOffset CreatedAt { get; init; } = DateTimeOffset.UtcNow;
public DateTimeOffset? UpdatedAt { get; init; }
public long Version { get; init; } = 1;
public virtual string GetPartitionKey() => Id;
public virtual string? GetSortKey() => null;
}

FeatureRepositoryRaw Items
Type safetyYesNo
Schema validationYesNo
Auto-generated IDsYesNo
TimestampsAutomaticManual
VersioningBuilt-inManual
Best forDomain entitiesFlexible data