GithubHelp home page GithubHelp logo

nosqlite's Introduction

NoSQLite: NoSQL on top of SQLite

Release NuGet MIT License

A thin wrapper above sqlite using the JSON1 apis turn it into a NOSQL database.

This library references and uses SQLitePCLRaw.bundle_e_sqlite3 version 2.1.2 and later witch ensures that the JSON1 APIS are present.

The library executes Batteries.Init(); for you when a connection is first initialized.

Getting Started

Create an instance of NoSQLiteConnection.

var connection = new NoSQLiteConnection(
    "path to database file", // Required
    json_options)            // Optional JsonSerializerOptions

The connection configures the PRAGMA journal_mode to be WAL

The connection manages an sqlite3 object when initialized. You should always dispose it when you are done so that the databases flashes WAL files but you can also ignore it ¯\ (ツ)/¯.

Tables

You get a table using connection.GetTable() you can optionaly provide a table name or leave it as it is to get the default documents table.

Tables are created if they do not exist.

Tables are managed by their connections so you don't have to worry about disposing. If you request a table multiple times (eg: the same name) you will always get the same Instance.

Document Management

Example class that will be used below:

public class Person
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public string? Description { get; set; }
}
var connection = new NoSQLiteConnection("path to database file", "json options or null");
var docs = connection.GetTable();

Create/Update documents.

Creating or Updating a document happens from the same Insert method, keep in mind that this always replaces the document with the new one.

var panos = new Person
{
    Name = "panoukos",
    Surname = "41",
    Description = "C# dev"
}

docs.Insert("panos", panos); // If it exists it is now replaced/updated.

Get documents.

var doc = docs.Get<Person>("panos"); // Get the document or null.

Delete documents.

docs.Remove("panos"); // Will remove the document.
docs.Remove("panos"); // Will still succeed even if the document doesn't exist.

Build

To build this project .NET 7 is needed.

Contribute

Contributions are welcome and appreciated, before you create a pull request please open a GitHub Issue to discuss what needs changing and or fixing if the issue doesn't exist!

nosqlite's People

Contributors

panoukos41 avatar

Stargazers

 avatar

Watchers

 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.