SQLwith partial.js (mySQL and PostgreSQL - Pg)

34 views
Skip to first unread message

Hasan A Yousef

unread,
Nov 23, 2013, 3:15:01 PM11/23/13
to part...@googlegroups.com
Peter,
Thanks a lot for your help, time and efforts with me to start partial.j and node.js, and help in he last days to connect them with SQL database, both PostgreSQL and mySQL.

As I thing the effort spent may be help full for others, I'm attaching here the starting of both of them, that other users may build on, not sure if publishing them here is suitable, or may you like to modify them, and add them to the partial.js examples, and documentation.

Regards,
Hasan
mySQL-sample.zip
pg-sample.zip

Peter Širka

unread,
Nov 23, 2013, 3:49:52 PM11/23/13
to part...@googlegroups.com
Super, thanks :-)
I updated your examples.
postgreSQL-sample.zip
mySQL-sample.zip

arief nur andono

unread,
Nov 26, 2013, 8:21:46 PM11/26/13
to part...@googlegroups.com
wow..so great...thanks peter & hasan..

arief nur andono

unread,
Nov 26, 2013, 8:32:09 PM11/26/13
to part...@googlegroups.com
I got this error..

/home/arief/programming/nodejs/mySQL-sample/mySQL-sample/controllers/default.js:40
}
^
SyntaxError: Unexpected token }
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at EventEmitter.Framework.controller (/home/arief/programming/nodejs/mySQL-sample/mySQL-sample/node_modules/partial.js/index.js:259:12)
    at /home/arief/programming/nodejs/mySQL-sample/mySQL-sample/node_modules/partial.js/index.js:615:9
    at Array.forEach (native)
    at EventEmitter.Framework.install (/home/arief/programming/nodejs/mySQL-sample/mySQL-sample/node_modules/partial.js/index.js:609:23)

arief nur andono

unread,
Nov 26, 2013, 8:43:39 PM11/26/13
to part...@googlegroups.com
just add ); in line 39 in it works (don't forget to create database and edit template/users.html to remove comment)
function view_homepage() {

    var self = this;
    var connection = self.database('test');

    // Connect to mySql (if there is an erro, report it and terminate de request)
    connection.connect(function(err){

        if(err != null) {
            self.view500(err);
            return;
        }

        // Query the database to some data
        // User = { Id: Number, Age: Number, Name: String };

        connection.query('SELECT * FROM users', function(err, rows) {

            // There was a error or not?
            if (err != null) {
                self.view500(err);
            }
            else {
                // Shows the result on console window
                console.log(rows);
            }

            // Close connection
            connection.end();

            // Send rows as the model into the view
            self.view('homepage', rows);
        });
    });
}

Peter Širka

unread,
Nov 27, 2013, 2:09:28 AM11/27/13
to part...@googlegroups.com
Ahh, sorry ... yes.

IMPORTANT: edit template/users.html to remove comment (BAD)

Read more about HTML comments in templates:

Many thanks :-)


Reply all
Reply to author
Forward
0 new messages