Search for Orm2 https://github.com/dresende/node-orm2 on GitHub;
Download it in the project folder using NPM install ORM and then write the configuration file
varORM = require ("ORM"); Orm.connect ("Mysql://username:[email Protected]/database",function(err, db) {if(ERR)Throwerr; varperson = db.define (' person ', {name:string, surname:string, Age:number,//FLOATMale:boolean, continent: ["Europe", "America", "Asia", "Africa", "Australia", "Antartica"],//ENUM TypePhoto:buffer,//blob/binaryData:object//JSON encoded}, {methods: {fullName:function () { return This. Name + "+ This. Surname; }}, validations: {Age:orm.enforce.ranges.number (Undefined, "under-age") } }); //Add the table to the databaseDb.sync (function(err) {if(ERR)Throwerr; //add a row to the person tablePerson.create ({id:1, Name: "John", Surname: "Doe", age:27},function(err) {if(ERR)Throwerr; //query the person table by surnamePerson.find ({surname: "Doe"},function(err, people) {//SQL: "SELECT * from the person WHERE surname = ' Doe '" if(ERR)Throwerr; Console.log ("People found:%d", people.length); Console.log ("First Person:%s, age%d", People[0].fullname (), people[0].age); people[0].age = 16; people[0].save (function(err) {//err.msg = "under-age"; }); }); }); });});
Specific configuration View ORM documentation on GitHub
Nodejs connecting MySQL Database