Git Product home page Git Product logo

litedb.webassembly's Introduction

LiteDB for Blazor - WebAssembly

This repository contains some cool tests about LiteDB and ASP.NET Blazor in client side (WebAssembly). This is not a final product! (yet ๐Ÿ˜„)

How will works

LiteDB.WebAssembly forks LiteDB v5.1 branch with master updates to start a smaller and focused version for wasm. Some LiteDB was removed in this version (maybe can back in future).

Blazor runs in browser using WebAssembly. There is no disk access in browsers so all your data will be sotored into IndexedDB and/or LocalStorage. Works with a single database per domain and async read/write operations only. All locks will be removed and there is no support for concurrency or transactions (exclusive lock only).

All methods are converted into async and has an Async sufix. Also, this version needs to run await OpenAsync() before use database.

Removed features

  • Encryption
  • Transactions
  • Shared Connection
  • FileStorage
  • SortDisk

How to use

Register ILiteDatabase service with a custom Stream. You can use MemoryStream, LocalStorageStream or IndexedDBStream (not yet).

// in memory database
builder.Services.AddScoped<ILiteDatabase>(sp => new LiteDatabase(new MemoryStream()));

// store data in local storage
builder.Services.AddScoped<ILiteDatabase>(sp => new LiteDatabase(new LocalStorageStream()));

You must call open database before use

@page "/db-demo"
@inject ILiteDatabase _db;

    private ILiteCollection<Person> _personCollection;

    protected override async Task OnInitializedAsync()
    {
        await _db.OpenAsync();
        
        _personCollection = _db.GetCollection<Person>();
    }

litedb.webassembly's People

Contributors

mbdavid avatar andreatosato avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.