From 474f42cde4df81918116d8ee39f800d69ded4a07 Mon Sep 17 00:00:00 2001 From: FullGreaM Date: Sat, 31 Jul 2021 22:01:30 +0300 Subject: [PATCH] up-date information about module --- README.md | 2 +- README.md.save | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 README.md.save diff --git a/README.md b/README.md index eab8bdb..328bb2a 100644 --- a/README.md +++ b/README.md @@ -114,5 +114,5 @@ console.log(data); ``` output... ```javascript -[objecObject] +[{'ID': 0, 'content': 'content 1'}, {'ID': 1, 'content': 'other content'}, {'ID': 2, 'content': 'Content number 3 :)'}, {'ID': 3, 'content': 'etc.'}] ``` diff --git a/README.md.save b/README.md.save new file mode 100644 index 0000000..6c3c2bd --- /dev/null +++ b/README.md.save @@ -0,0 +1,118 @@ +# SQLEasy.js +module for simple works from sqlite3 (JavaScript edition) +## Prepare for work +My module use module **better-sqlite3**, you must download it. +```bash +npm install better-sqlite3 +``` +from next, you can download folder of project, and load in folder "node_modules" +``` bash +cd node_modules +git clone https://github.com/Nikiroy78/SQLEasy.js.git +``` +import database object in your project +``` javascript +const SQLEasy = require('SQLEasy.js'); +var database = SQLEasy.database('/path/to/database.db'); +``` +This object have 4 methods: add, remove, set, get +### get +This method getting date from included database +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +console.log(database.get('table')); +``` +output... +``` javascript +[{'ID': 0, 'content': 'content 1'}, {'ID': 1, 'content': 'other content'}, {'ID': 2, 'content': 'Content number 3 :)'}, {'ID': 3, 'content': 'etc.'}] +``` + +You can apply condition's settings from filt your data... +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +console.log(database.get('table', [{'ID': 0}, {'content': 'etc.'}])); +``` +output... +``` javascript +[{'ID': 0, 'content': 'content 1'}, {'ID': 3, 'content': 'etc.'}] +``` +Response show is... +```SQL +SELECT * FROM table WHERE (ID=0) OR (content='etc.') +``` +And you edit uploaded columns +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +console.log(database.get('table', [{'ID': 0}, {'content': 'etc.'}], 'content')); +``` +output... +``` javascript +[{'content': 'content 1'}, {'content': 'etc.'}] +``` +Response show is... +```SQL +SELECT content FROM table WHERE (ID=0) OR (content='etc.') +``` +### add +This is sql response +```SQL +INSERT +``` +Using add method in your code (from your simply, we used old date from last database). +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +database.add('table', [{'ID': 4, 'content': 'test example, from fucking tests :)'}]) +console.log(database.get('table')); +``` +output... +```javascript +[{'ID': 0, 'content': 'content 1'}, {'ID': 1, 'content': 'other content'}, {'ID': 2, 'content': 'Content number 3 :)'}, {'ID': 3, 'content': 'etc.'}, {'ID': 4, 'content': 'test example, from fucking tests :)'}] +``` +### remove +Using remove method in your code (from your simply, we used old date from last database). +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +database.remove('table', {'ID': 4}); +console.log(database.get('table')); +``` +output... +```javascript +[{'ID': 0, 'content': 'content 1'}, {'ID': 1, 'content': 'other content'}, {'ID': 2, 'content': 'Content number 3 :)'}, {'ID': 3, 'content': 'etc.'}] +``` +### set +Using set method in your code (from your simply, we used old date from last database). +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database.db'); + +database.set('table', {'ID': 3}, {'content': 'edited'}); // First param - index key, found param - edit content... +console.log(database.get('table')); +``` +output... +```javascript +[{'ID': 0, 'content': 'content 1'}, {'ID': 1, 'content': 'other content'}, {'ID': 2, 'content': 'Content number 3 :)'}, {'ID': 3, 'content': 'edited'}] +``` +### execute +This is important method from execute your SQL script in your code. +Using method **execute** in test code (from your simply, we used old date from last database). +```javascript +const sqlite = require('SQLEasy.js'); +var database = sqlite.database('/path/to/database'); + +var data = database.execute('SELECT * FROM table'); +console.log(data); +``` +output.log +```javascript +git clone https://github.com/Nikiroy78/SQLEasy.js.git +```