The light and minimalist ORM for sqlite 3
This project is currently under development.
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);// falseimport{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 definionPor su interes, gracias =)
Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.
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 installThis 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 lintnpm test...
"Pendiente", on this moment you pull and push 😄
