nedgedb
Node module for Progress OpenEdge database with nosql front end interface.
Description
This library helps you perform CRUD operations on OpenEdge Database both synchronuosly or asynchronously from a node.js application. The node module communicates with the ODBC drivers installed which in turn fetches records from the database as JSON objects.
Installation
npm install nedgedb
For linux
Requires installed unixODBC
- Ubuntu/Debian
$ sudo apt-get unixodbc unixodbc-dev
- Fedora/Red Hat/CentOS
$ sudo yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
- Proper odbc configuration, follow the steps here to correctly configure your odbc installation
Configuring OpenEdge
Set progress environment by the command proenv. Prodb creates a database. Proserve starts the OpenEdge database on a specific port number
proenvprodb "databasename_to_be_copied" "databasename_to_be_copied_to"proserve "databasename" -S "portnumber"
We would be required to use prodb only for the first time.
Sample Programs
Note : Replace the dsn_name, user_name, password and table_name in the following sample programs with the actual credentials of your openedge database
Sync Implementation
var nedgedb = ; var db = "dsn_name""user_name""password"; var records=;var collection; var err = db;iferr throw err;else console; collection = db; var query = "column1" : "$eq" : 22222 ;var list = column1column2...;var order = CustNum : 1;var limit = 30;/* collection.find() attributes: 1.query (Where clause of SQL given in json similar to mongodb) 2.list (All the columns that are to be fetched to be given in an array) 3.order (Sorted order of the given records to be given in json similat to mongodb) 4.limit (SQL_limit) 5.callback (A cursor to records is returned if the callback is not used) If the callback is not given it everything in find happens in Sync(similar to findSync)*/collection;console; err = db;iferr throw err;else console;
Async Implementation
var nedgedb = ;var db ="dsn_name""user_name""password"; var collection = db; db; console;
Async CRUD Operations
//Async Crud Implementationvar nedgedb = ; var db ="mydsn""pmanyam"""; var collection = db; query = "CustNum" : "$eq" : 22222 ; var record = CustNum : '22222' Name : 'puneeth' var record2 = CustNum : 22222 Name : "Raju" var list = "CustNum""Name";var order = CustNum : 1; db;console;
Cursor Usage
//Cursor Implementationvar nedgedb = ; var db = "dsn_name""user_name""password"; var collection = db; var { iferr throw err; else console; console; } var err = db;iferr throw err;else console; /* If the callback was not provided for the collection.find or collection.findSync a cursor to the records is returned Cursor functionalities: --> cursor.err => Error in fetching records --> cursor.cur_record => Current record number(-1 if no records are fetched) --> cursor.records => Fetched Records in an array --> cursor.len => No.of records fetched --> cursor.record(callback(err,res)) gives the present record in res and err in accessing the record in err. err = "No_Records" if no records are fetched. = "End_Of_Records" if present record number was more than the number of fetched records = "Negative" if a negative record number was attempted to access = error in fetching otherwise = 0 if everything was fine --> cursor.next(offset) skips offset number of records. offset can be +ve or -ve. If no offset is given a default of 1 is taken --> cursor.rewind() rewinds the cursor --> cursor.end() takes the cursor to end*/var cursor = collection; cursor; cursornext;cursor; cursor;cursor; cursor;cursor; cursor;cursornext4;cursor; err = db;iferr throw err;else console;