Skip to content

Repository files navigation

minSQLite

The light and minimalist ORM for sqlite 3

This project is currently under development.

Model example:

Trying

utils (src/Utils.js)

import{utils}from''min-sqlite;// strFormatutils.strFormat('SELECT $fields FROM $name WHERE $conds ;','*','users','id = 1');// return// SELECT users FROM users WHERE id = 1 ;// method hasconstundef=undefined;constarr=[12,4,5,6];utils.has(null,'x');// falseutils.has(undef,'y');// falseutils.has({},undef));// falseutils.has(arr,0))// trueutils.has(arr,arr.length-1);// trueutils.has(arr,arr.length);// true// method sleepasyncfunctionsomeFunc(){awaitutils.sleep(1000);// sleeping 1s// ... more code}// immutable ObjectconstobjImmutable=utils.immutable({betzy: '💘',fitorec: '🤓'});// return { betzy: '💘', fitorec: '🤓' }objImmutable.betzy// '💘'objImmutable.fitorec// '🤓'objImmutable.betzy=6;// Exception Error: Immutable!objImmutable.firorec='x';// Exception Error: Immutable!objImmutable.newProp='some value';// Exception Error: Immutable!objImmutable.betzy// '💘' (no changed)objImmutable.fitorec// '🤓' (no changed)utils.has('newProp',objImmutable);// false

SQLite3 types (src/Types.js)

import{types}from''min-sqlite;types.list();// List of available typestypes.INTEGER// an object type INTEGERtypes.VARCHAR(30)// an object type VARCHAR with length 30constbol=types.create('BOOLEAN');// an object type BOOLEANtypes.withLen()// [ 'VARCHAR', 'NVARCHAR','CHARACTER', 'NCHAR' ]types.withLen('VARCHAR');// truetypes.withLen('BOOLEAN');// alsetypes.normalizeAttr('unique',1);// truetypes.cast.BOOLEAN(1);// truetypes.cast.BOOLEAN('0');// falsetypes.cast.INTEGER('123.23');// 123types.cast.FLOAT('123.23');// 123.23types.cast.TEXT('123.23');// '123.23' (String)constinteger=types.INTEGER;// create a type Integertypes.is(type);// truetypes.is(bol);// truetypes.is(types.VARCHAR(4));// truetypes.is({});// falsetypes.is(null);// falsetypes.DEFAULT.ai=true;// No mutation, no errorsconsole.log(types.DEFAULT.ai);// false (original value)types.columnSQLDefinition(columnName,integer)// return SQL column definion

Contributing Guide

Por su interes, gracias =)

Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

Setting up your environment

After forking to your own github org, do the following steps to get started:

# clone your fork to your local machine
git clone https://github.com/<you-user>/minSQLite
# step into local repocd minSQLite
# install dependencies
npm install

Style & Linting

This codebase adheres to the Airbnb Styleguide and is enforced using ESLint.

It is recommended that you install an eslint plugin for your editor of choice when working on this codebase, however you can always check to see if the source code is compliant by running:

npm run lint

Testing

npm test

Pull Request Guidelines

...

"Pendiente", on this moment you pull and push 😄

About

The light and minimalist ORM for sqlite 3

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages