Documentation
Untitled-modelRapid sql query generator extention for node.
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using the
npm install
command:
$ npm install untitled-model
test installation
$ node> var model = require('untitled-model')>
Follow our installing guide for more information.
Features
- Mysql database support
- Fetching data from database from sql
- Fetching data from relational database [foreign key]
- row SQL query [ all / filter / values / update / delete ]
Security Issues
If you discover a security vulnerability in untitled-model
, please see Security Policies and Procedures.
Quick Start
Start new project
$ mkdir myWeb && cd myWeb$ node init$ node i untitled-model
Create model:
# make sure your current dir should be ~/myWeb/ $ mkdir models$ touch ./models/user.json
User model :
Copy and past this inside ~/models/user.json
Migrating models
/myWeb/test.js
var model = ;model;model;
Philosophy
The untitled-model philosophy is to provide a tool for programmers to send and receive
data to and from sql database.
Migrate function is use to generate tables inside database.
It supports relational database foreign key
concept.
foreign key
department.json
user.json
Functions
-
### User = model.get('user')
User =model: 'user'all: Functionfilter: Functionvalues: Functionupdate: Functioninsert: Functiondelete: Functionm:model: 'user'select:FILTER:join: ''buffer:show: Functionvalue: Functionfilter_: Functionvalues: Functionfilters: Functionrename: Function -
##### User.all(callback)
requires sql connection
// It returns data to callback unction{let table = thismodel;let project = thismselect;query = "select " +select+" from " + table ;;}Example:Userall{ife throw e;console;}; -
##### User.filter({},callback)
requires sql connection
// It returns data to callback unction{let table = thismodel;let project = thismselect;query = "select " +select+" from " + table + " WHERE " + filters;;}Example:User;User;User;User; -
##### User.values(['attr'])
sql projection
- use __ for foreign table// It returns data to callback unction{_set_select_vlaues_return thism;}Example:User = UserUserall{iferror throw error;console;};// orUser = UserUser
- ##### show()
// returns Query string
- ##### rename({})
// rename the attributes in query string
; - filter(callback)
- all(callback)
- ##### show()
- use __ for foreign table
-
##### update({})
returns model
User; -
##### insert({}, callback)
insert into database
User; -
##### delete().filter({},callback)
delete from database
User;