Skip to content

themost-framework/sqlite

Repository files navigation

test npm Libraries.io dependency status for latest release, scoped npm package GitHub top language License GitHub last commit GitHub Release Date npm

MOST Web Framework Logo

@themost/sqlite

MOST Web Framework SQLite Data Adapter

License: BSD-3-Clause

Install

npm install @themost/sqlite

Usage

Register SQLite adapter on app.json as follows:

"adapterTypes": [
    ...
      { "name":"SQLite Data Adapter", "invariantName": "sqlite", "type":"@themost/sqlite" }
    ...
    ],
adapters: [
    ...
    { 
        "name":"local-db", "invariantName":"sqlite", "default":true,
        "options": {
            database:"db/local.db"
        }
    }
    ...
]

}

or create a new instance of SqliteAdapter class for connecting to SQLite database.

const { SqliteAdapter } = require('@themost/sqlite');
const { QueryExpression } = require('@themost/query');
const db = new SqliteAdapter({
    database: 'db/local.db'
});
const query = new QueryExpression()
    .select(({ id, name, category, model, price }) => ({
        id,
        name,
        category,
        model,
        price,
    })).from('ProductData')
    .where((x) => {
        return x.price > 500 && x.category === "Laptops";
    })
    .orderByDescending((x) => x.price)
    .take(10);
const items = await db.executeAsync(query);

Read more about MOST Web Framework query language provided by @themost/query

Use query playground project at codesanbox.io to learn more about the query language specification of @themost-framework

codesandbox.io_query-playground-1.png