{"id":18036308,"url":"https://github.com/nightroman/ldbc","last_synced_at":"2025-03-27T08:30:40.259Z","repository":{"id":37542728,"uuid":"238541179","full_name":"nightroman/Ldbc","owner":"nightroman","description":"LiteDB Cmdlets, the document store in PowerShell","archived":false,"fork":false,"pushed_at":"2024-07-06T03:53:19.000Z","size":239,"stargazers_count":41,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T10:51:08.168Z","etag":null,"topics":["litedb","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nightroman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["nightroman"]}},"created_at":"2020-02-05T20:23:53.000Z","updated_at":"2024-10-12T00:09:55.000Z","dependencies_parsed_at":"2024-02-19T20:38:26.470Z","dependency_job_id":"05d8511d-98a3-446f-b627-03c9c39e1354","html_url":"https://github.com/nightroman/Ldbc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FLdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FLdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FLdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FLdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightroman","download_url":"https://codeload.github.com/nightroman/Ldbc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245809600,"owners_count":20676017,"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","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":["litedb","powershell"],"created_at":"2024-10-30T12:12:27.776Z","updated_at":"2025-03-27T08:30:39.893Z","avatar_url":"https://github.com/nightroman.png","language":"PowerShell","funding_links":["https://github.com/sponsors/nightroman"],"categories":[],"sub_categories":[],"readme":"# Ldbc\r\n\r\nLiteDB Cmdlets, the document store in PowerShell\r\n\r\n***\r\n\r\nLdbc is the PowerShell module with [LiteDB](https://www.litedb.org),\r\na small, fast, zero configuration NoSQL embedded database.\r\n\r\n- Ldbc works with Windows PowerShell and PowerShell Core.\r\n- LiteDB is included and ready to use without installing anything.\r\n\r\nSome LiteDB features:\r\n\r\n- Single datafile\r\n- ACID transactions\r\n- Store files and stream data\r\n- Cross collections references\r\n- Recovery after writing failures\r\n- Mapping classes to documents\r\n\r\nLdbc makes LiteDB operations and data PowerShell friendly. You can store and\r\nretrieve hashtables and dictionaries, PowerShell classes and custom objects,\r\n.NET complex types. Operate on data using specialized cmdlets or LiteDB SQL.\r\n\r\n## Quick start\r\n\r\n**Step 1:** Get and install\r\n\r\nLdbc is published as the [PSGallery module](https://www.powershellgallery.com/packages/Ldbc).\r\n\r\nYou can install the module by this command:\r\n\r\n```powershell\r\nInstall-Module Ldbc\r\n```\r\n\r\n**Step 2:** In a PowerShell command prompt import the module:\r\n\r\n```powershell\r\nImport-Module Ldbc\r\n```\r\n\r\n**Step 3:** Take a look at help and available commands:\r\n\r\n```powershell\r\nhelp about_Ldbc\r\nGet-Command -Module Ldbc\r\nhelp Use-LiteDatabase -Full\r\n```\r\n\r\n**Step 4:** Try add, get, remove operations with a memory database\r\n\r\n(a) using `Add-LiteData`, `Get-LiteData`, `Remove-LiteData`:\r\n\r\n```powershell\r\nUse-LiteDatabase :memory: {\r\n    # get the collection, specify auto id\r\n    $test = Get-LiteCollection Test Int32\r\n\r\n    # add two documents\r\n    @{Name = 'John'}, @{Name = 'Mary'} | Add-LiteData $test\r\n\r\n    # find using filter with an argument\r\n    $r = Get-LiteData $test -Where 'Name = @0', John\r\n    \"$r\" # {\"_id\":1,\"Name\":\"John\"}\r\n\r\n    # remove one by _id\r\n    Remove-LiteData $test -ById 1\r\n\r\n    # get all documents\r\n    $r = Get-LiteData $test\r\n    \"$r\" # {\"_id\":2,\"Name\":\"Mary\"}\r\n}\r\n```\r\n\r\n(b) ditto using just `Invoke-LiteCommand` and LiteDB SQL:\r\n\r\n```powershell\r\nUse-LiteDatabase :memory: {\r\n    # add two documents\r\n    Invoke-LiteCommand 'INSERT INTO Test : INT VALUES {Name: \"John\"}, {Name: \"Mary\"}' -Quiet\r\n\r\n    # find using WHERE with parameters\r\n    $r = Invoke-LiteCommand 'SELECT $ FROM Test WHERE Name = @param1' @{param1 = 'John'}\r\n    \"$r\" # {\"_id\":1,\"Name\":\"John\"}\r\n\r\n    # remove using WHERE with parameters\r\n    Invoke-LiteCommand 'DELETE Test WHERE _id = @_id' @{_id = 1} -Quiet\r\n\r\n    # get all documents\r\n    $r = Invoke-LiteCommand 'SELECT $ FROM Test'\r\n    \"$r\" # {\"_id\":2,\"Name\":\"Mary\"}\r\n}\r\n```\r\n\r\n(c) store and retrieve PowerShell custom objects\r\n\r\n```powershell\r\nUse-LiteDatabase :memory: {\r\n    # get the collection\r\n    $test = Get-LiteCollection Test\r\n\r\n    # get PS objects, select some properties, insert\r\n    Get-ChildItem | Select-Object Name, Mode, Length | Add-LiteData $test\r\n\r\n    # get back PS custom objects\r\n    Get-LiteData $test -As PS\r\n}\r\n```\r\n\r\n**Next steps**\r\n\r\nRead cmdlets help with basic examples. Take a look at tests in the repository\r\nfor more technical examples.\r\n\r\nRead LiteDB [docs](https://www.litedb.org/docs/).\r\nSome API may be needed and used directly in addition to provided by the module.\r\n\r\n## LiteDB methods and module commands\r\n\r\n| LiteDB | Module  | Output\r\n| :----- | :-----  | :-----\r\n| **Database** | |\r\n| LiteDatabase | New-LiteDatabase | database (needs Dispose)\r\n| LiteDatabase | Use-LiteDatabase {..} | $Database (auto Dispose)\r\n| GetCollection | Get-LiteCollection | collection instance\r\n| Execute | Invoke-LiteCommand | values, documents\r\n| BeginTrans | Use-LiteTransaction {..} | ..\r\n| + Commit | (success) |\r\n| + Rollback | (failure) |\r\n| **Collection** | |\r\n| Count | Get-LiteData -Count | count\r\n| Exists | Test-LiteData | true or false\r\n| Find* | Get-LiteData | documents\r\n| Insert | Add-LiteData | none, ids\r\n| Update | Set-LiteData | none, count\r\n| Upsert | Set-LiteData -Add | none, count\r\n| UpdateMany | Update-LiteData | none, count\r\n| DeleteMany | Remove-LiteData | none, count\r\n| **Misc** | |\r\n| RegisterType | Register-LiteType | none\r\n\r\n## Work in progress\r\n\r\nWork on module commands and features is in progress, they may change before v1.0.0\r\n\r\n## See also\r\n\r\n- [Ldbc Release Notes](https://github.com/nightroman/Ldbc/blob/main/Release-Notes.md)\r\n- [about_Ldbc.help.txt](https://github.com/nightroman/Ldbc/blob/main/Module/en-US/about_Ldbc.help.txt)\r\n- [Mdbc, similar project for MongoDB](https://github.com/nightroman/Mdbc)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Fldbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightroman%2Fldbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Fldbc/lists"}