{"id":19586414,"url":"https://github.com/halforbit/document-stores","last_synced_at":"2025-08-31T13:34:29.107Z","repository":{"id":89122840,"uuid":"345529173","full_name":"halforbit/document-stores","owner":"halforbit","description":"Document Stores lets you easily create queryable stores with strongly-typed keying over document databases like CosmosDb, without the need for high-ceremony repository patterns or bare-metal integrations.","archived":false,"fork":false,"pushed_at":"2023-08-29T06:04:13.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-26T20:36:51.806Z","etag":null,"topics":["cosmosdb","document-database","iqueryable","sql"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halforbit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-08T04:23:07.000Z","updated_at":"2023-08-29T06:09:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f0c59a2-febf-440b-8a0f-e4b00c71a4cb","html_url":"https://github.com/halforbit/document-stores","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/halforbit/document-stores","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halforbit%2Fdocument-stores","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halforbit%2Fdocument-stores/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halforbit%2Fdocument-stores/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halforbit%2Fdocument-stores/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halforbit","download_url":"https://codeload.github.com/halforbit/document-stores/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halforbit%2Fdocument-stores/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272527950,"owners_count":24949956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cosmosdb","document-database","iqueryable","sql"],"created_at":"2024-11-11T07:59:39.738Z","updated_at":"2025-08-31T13:34:29.102Z","avatar_url":"https://github.com/halforbit.png","language":"C#","readme":"# Halforbit Document Stores\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) \u0026nbsp;[![Build status](https://ci.appveyor.com/api/projects/status/jncopu91kmdi38p5?svg=true)](https://ci.appveyor.com/project/halforbit/document-stores) \u0026nbsp;[![Nuget Package](https://img.shields.io/nuget/v/Halforbit.DocumentStores.svg)](#nuget-packages)\n\nDocument Stores lets you easily create queryable stores with strongly-typed keying over document databases like CosmosDb, without the need for high-ceremony repository patterns or bare-metal integrations.\n\n## Features\n\n- **Queryable:** Document stores let you use `IQueryable` or SQL language to query for strongly- or dynamically-typed documents.\n  \n- **Easy Strongly-Typed Keying:** Define partition keys and document IDs as properties using simple lambda expressions.\n\n- **No Repository Pattern Needed:** Ditch the hand-made, error-prone, high-ceremony repository implementations.\n\n## Getting Started\n\n1. **Install NuGet Packages:** Install the NuGet packages for your desired storage providers and formats:\n    ```powershell\n    Install-Package Halforbit.DocumentStores.CosmosDb\n    ```\n    See the [NuGet Packages](#nuget-packages) section below for a list of available NuGet packages and what storage providers and formats they support.\n\n2. **Define Your Stores:** Use the `DocumentStore` type to create ad-hoc stores, or define them as properties on a data context.\n   \n3. **Use Your Stores:** Persist, retrieve, and query data with your stores.\n\nA store can be defined as a property of a **data context**, or created **ad-hoc** and stored in a local variable.\n\n## Example Usage\n\n### What do you want to store?\n\nTo create a document store, first decide on your **document type**. This can be any JSON-friendly `class`, `record`, or `JObject`. Let's make a record to track a person:\n\n```csharp\npublic record Person(\n    Guid PersonId,\n    string FirstName,\n    string LastName);\n```\n\nOur document type has a `Guid` **key property** named `PersonId`. Key properties can be simple value types like `Guid`, `int`, and `string`. \n\nFor more information on keying, see [Keying with Halforbit Document Stores](keying.md).\n\n### Build a Document Store\n\nUse the fluent builder to describe and create your document stores:\n\n```csharp\nIDocumentStore\u003cGuid, Person\u003e store = DocumentStore\n    .Describe()\n    .CosmosDb()\n    .ConnectionString(\"\u003cconnection-string-here\u003e\")\n    .Database(\"test-database\")\n    .Container(\"test-container\")\n    .Document\u003cPerson\u003e()\n    .Key(d =\u003e d.PersonId)\n    .Build();\n```\n\nIf your database or container do not exist, you can use your store to create them:\n\n```csharp\nawait store.CreateStoreIfNotExistsAsync();\n```\n\n### Put a document in a store\n\nLet's create a `Person` and put it in our document store:\n\n```csharp\nvar person = new Person(\n    PersonId: Guid.NewGuid(),\n    FirstName: \"Steve\",\n    LastName: \"Smith\");\n\nawait store.UpsertAsync(person);\n```\n\n### Get a document from a store\n\nYou can get a document with its key:\n\n```csharp\nvar person = await store.GetAsync(personId);\n```\n\n### Query the documents in a store\n\nYou can use LINQ `IQueryable` or raw SQL to query your store with the `QueryAsync` methods. The results are given to you as an `IAsyncEnumerable\u003c\u003e`.\n\n```csharp\nawait foreach (var person in store.QueryAsync(q =\u003e q\n    .Where(p =\u003e p.LastName == \"Smith\")))\n{\n    // do something with person here.\n}\n```\n\n### Delete a document from a store\n\nYou can delete a document with its key:\n\n```csharp\nawait store.DeleteAsync(personId);\n```\n\n\n\u003ca name=\"nuget-packages\"\u003e\u003c/a\u003e\n\n## NuGet Packages\n\nThe following NuGet packages are provided, parted out by their dependencies. Install the ones that contain the storage providers and formats you wish to use.\n\n| Storage Provider or Format | NuGet Package |\n|----------------------------|---------------|\n| (Base Library) | [`Halforbit.DocumentStores`](https://www.nuget.org/packages/Halforbit.DocumentStores) |\n| Azure CosmosDb | [`Halforbit.DocumentStores.CosmosDb`](https://www.nuget.org/packages/Halforbit.DocumentStores.CosmosDb) |\n\n## License\n\nData Stores is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalforbit%2Fdocument-stores","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalforbit%2Fdocument-stores","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalforbit%2Fdocument-stores/lists"}