agentleFS
Sorcha-PlatformSorcha-Platform/Sorcha/.claude/skills/mongodb/SKILL.md

mongodb

Skill2 starsChanged 10 months agoMITView on GitHub

Configures MongoDB document storage and query operations for Sorcha's distributed ledger Use when: implementing document storage, querying collections, creating indexes, or working with Register/Transaction/Docket data

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use mcp__context7__resolve-library-id to search for "mongodb c# driver"

    line 104

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

MongoDB Skill

MongoDB is the document store for Sorcha's Register Service, providing storage for registers, transactions, dockets, and system blueprints. The codebase uses a two-tier storage architecture: warm-tier (mutable IDocumentStore<T>) and cold-tier (immutable IWormStore<T> for WORM/ledger data).

Quick Start

Connection Setup

// Program.cs - Register Service
builder.Services.AddSingleton<IMongoClient>(sp =>
{
    var connectionString = builder.Configuration.GetConnectionString("MongoDB") 
        ?? "mongodb://localhost:27017";
    return new MongoClient(connectionString);
});

builder.Services.AddSingleton<IMongoDatabase>(sp =>
{
    var client = sp.GetRequiredService<IMongoClient>();
    return client.GetDatabase("sorcha_register");
});

Repository Registration

// Use extension method from Sorcha.Storage.MongoDB
builder.Services.AddMongoClient(builder.Configuration);
builder.Services.AddMongoDatabase("sorcha_register");
builder.Services.AddMongoDocumentStore<Blueprint, string>(
    "blueprints",
    doc => doc.Id,
    doc => doc.Id
);

Key Concepts

ConceptUsageExample
Filter BuildersType-safe queriesBuilders<T>.Filter.Eq(x => x.Id, id)
Update BuildersAtomic updatesBuilders<T>.Update.Set(x => x.Height, 10)
Composite IndexesMulti-field queriesIndexKeys.Ascending(x => x.RegisterId).Ascending(x => x.TxId)
WORM StoreImmutable ledger dataIWormStore<Transaction, string> - no updates/deletes
Document StoreMutable documentsIDocumentStore<Blueprint, string> - full CRUD

Common Patterns

Filtered Query with Pagination

var filter = Builders<TransactionModel>.Filter.And(
    Builders<TransactionModel>.Filter.Eq(t => t.RegisterId, registerId),
    Builders<TransactionModel>.Filter.Gte(t => t.TimeStamp, since)
);

var results = await _collection
    .Find(filter)
    .SortByDescending(t => t.TimeStamp)
    .Skip(page * pageSize)
    .Limit(pageSize)
    .ToListAsync(cancellationToken);

Array Element Query

// Find transactions where address is in RecipientsWallets array
var filter = Builders<TransactionModel>.Filter.AnyEq(
    t => t.RecipientsWallets, 
    walletAddress
);

See Also

  • patterns
  • types
  • modules
  • errors

Related Skills

  • dotnet - Runtime and C# patterns
  • entity-framework - Alternative ORM (PostgreSQL uses EF)
  • redis - Caching layer integration
  • docker - MongoDB container setup
  • xunit - Integration tests with Testcontainers

Documentation Resources

Fetch latest MongoDB C# driver documentation with Context7.

How to use Context7:

  1. Use mcp__context7__resolve-library-id to search for "mongodb c# driver"
  2. Query with mcp__context7__query-docs using the resolved library ID

Library ID: /mongodb/mongo-csharp-driver

Recommended Queries:

  • "filter builder examples CRUD operations"
  • "BSON serialization attributes"
  • "index creation async"
  • "aggregation pipeline C#"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.