{"id":15177731,"url":"https://github.com/jpnantcom/blazor-sqlite","last_synced_at":"2025-10-16T09:32:27.368Z","repository":{"id":257095730,"uuid":"857302423","full_name":"jpnantcom/blazor-sqlite","owner":"jpnantcom","description":"Use SQLite Database in Blazor using SQLite wasm","archived":false,"fork":false,"pushed_at":"2025-01-22T04:15:01.000Z","size":530,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T03:13:10.026Z","etag":null,"topics":["blazor","blazor-webassembly","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jpnantcom.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}},"created_at":"2024-09-14T09:40:06.000Z","updated_at":"2025-01-22T04:15:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba8ed1c8-f5d5-446e-b9d1-5dee599e1c82","html_url":"https://github.com/jpnantcom/blazor-sqlite","commit_stats":{"total_commits":3,"total_committers":2,"mean_commits":1.5,"dds":"0.33333333333333337","last_synced_commit":"ff97f5dc58091e71d8582f5bf73559a71f879d06"},"previous_names":["jpnantcom/blazor-sqlite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpnantcom%2Fblazor-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpnantcom%2Fblazor-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpnantcom%2Fblazor-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpnantcom%2Fblazor-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpnantcom","download_url":"https://codeload.github.com/jpnantcom/blazor-sqlite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345266,"owners_count":21088244,"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":["blazor","blazor-webassembly","sqlite"],"created_at":"2024-09-27T14:42:50.670Z","updated_at":"2025-10-16T09:32:22.338Z","avatar_url":"https://github.com/jpnantcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NC-BlazorSQLite\nUses SQLite Database which runs entirely on Client Browser via SQLite wasm. Simple CRUD ORM which uses NewtonSoft JSON is provided for extra convinience.\n\n## Why you need this?\nNowadays, Browsers are more powerful than ever and you will find that most of the logic can be done on the browser itself.\n\nWhat if you can also store some data to be used with that logic as well?\n\n**Usecases:**\n- Local Cache with support for SQL queries.\n- Offload Complex Report Generation to Client Side.\n- Staging area for the data before sending it to the server.\n\n## Where the data is stored?\nBy default, the database is stored in memory and will be lost once the tab is closed.\n\nNote that this library was never intended to be used to store data permanently on the client browser and the SQLite WASM is loaded inside the worker thread which means `:localStorage:` and `:sessionStorage:` is not available and will fail.\n\nSQLite WASM provides options to persist the data, see: [Persistent storage options](https://sqlite.org/wasm/doc/trunk/persistence.md) for more details.\n\n## How to use\n\n1. Install Nuget Package\n2. In your component, add\n\n```csharp\n    [Inject]\n    public IJSRuntime JSRuntime { get; set; }\n    \n    private NCSqlite nCSqlite;\n\n    protected override Task OnInitializedAsync()\n    {\n        // initialize ncSQLite\n        nCSqlite = new NCSqlite(JSRuntime, \"test.db\");\n\n        return base.OnInitializedAsync();\n    }\n```\n\n3. Add `using Newtonsoft.Json.Linq` \n\n### Insert Data\nThe library can support most POCO and no additional mapping is required. Just use `.Upsert()` to insert data. Table with the same name as POCO type will be automatically created. \n\nFor attributes which are not String, Integer, Float, Boolean, Date - the value of that attribute is stored as JSON and NC-BlazorSQLite will automatically deserializes the JSON back for you.\n\nfrom this POCO:\n```csharp\n    public class MyData\n    {\n        public int Id { get; set; }\n\n        public string Value { get; set; }\n\n        public MyData Nested { get; set; }\n    }\n```\n\nUse:\n```csharp\n    await nCSqlite.Upsert(new MyData()\n        {\n            Id = 1,\n            Value = \"Outer\",\n            Nested = new MyData()\n            {\n                Id = 2,\n                Value = \"Inner\"\n            }\n        });\n```\n\n### Query Data\nTo Query data, NC-BlazorSQLite uses SQL Statement directly - there is no need to fear SQL injection attacks or anything, remember: this is a temporary database in Browser's memory!!\n\n```csharp\n    await nCSqlite.Execute(\"SELECT * FROM MyData\", (item) =\u003e\n    {\n        Console.WriteLine(item); // item is a JObject\n    });\n```\n\nYour handler function is called on each row returned by the statement. You can directly access each column by using `item[\"Value\"]` or convert the JObject into your own type using `item.ToObject\u003cMyData\u003e()`. This allows for aggregate or join queries which may not maps to any POCO you have.\n\nFor example:\n```csharp\n    await nCSqlite.Execute(\"SELECT 1\", (item) =\u003e\n    {\n        Console.WriteLine(item[\"1\"]); // print 1\n    });\n```\n\n### Run SQL Statement\nJust use Execute without the second argument.\n\n```csharp\n    await nCSqlite.Execute(\"DELETE FROM MyData\");\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpnantcom%2Fblazor-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpnantcom%2Fblazor-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpnantcom%2Fblazor-sqlite/lists"}