nosdb

2.0.1 • Public • Published

## NosDB Node.js Client

About NosDB

NosDB is a 100% native .NET Open Source NoSQL Database (released under the Apache 2.0 License). NosDB is extremely fast and linearly scalable and allows your .NET applications to handle extreme transaction loads (XTP). NosDB also helps you accelerate your .NET development by providing a flexible JSON schema. With JSON, you can quickly adjust to your changing requirements and lower your time to market and your cost of ownership.

About Node.js Client

Alachisoft has enabled you to use NosDB through Node.js by providing this client. Simply use this and open the world of NoSql to your Node.js applications.

How to install

      npm install nosdb

How to use

Perform following prerequisites and the sample code given below will execute without an issue.

  • Start Distributor Service (NosDistributorSvc).
  • Import Northwind sample data as explained in [InstallationDir]\samples\data\json\README.md of NosDB.
  • Provide correct password in the Connection String(connStr) hard-coded in the code below.
var nosDBClient = require('nosdb').nosDBClient;
var connStr = `data source=127.0.0.1 ; Database=northwind; Local Instance = false; 
        Distributor Address=127.0.0.1; Integrated Security=false; User Id=admin; password=4Islamabad;`;
// Get database using the connection string
 
nosDBClient.getDatabase(connStr, function (dbErr, db) {
    console.log(connStr);
    if (dbErr) throw dbErr;
    // Get instance of customers collection
    db.getCollection("Customers", function (collErr, customersCollection) {
        if (collErr) throw collErr;
        // Fetch customer from Customers collection
        getCustomer(db, function (err, reader) {
            if (err) throw err;
            reader.toArray(function (readerErr, array) {
                if (readerErr) throw readerErr;
                if (array[0]) {
                    var customerId = array[0].CustomerID;
                    var companyName = array[0].CompanyName;
                    var address = array[0].Address;
                    var city = array[0].City;
                    console.log("'" + array.length + "' record(s) retrieved");
                }
                else {
                    console.log("No document is retrieved against 'FRANK'.");
                }
            });
                // Release resources
            db.dispose();
        });                    
           
    });
});
 
/**
 * This method fetches customer from the collection
 * @param {dbCollection} coll collection from which customer will be fetched
 * @param {callback} callback callback that will be called after the operation
 */
var getCustomer = function (db, callback) {
    var getQueryCmd = {
        query: 'Select *  from Customers WHERE CustomerID = @customerId',
        parameters: [{ name: 'customerId', value: "FRANK" }]
    };
    db.executeReader(getQueryCmd, callback);
};

Requirements

NosDB 2.0 ENT or higher.

Additional Resources

Documentation

The complete online documentation for NosDB is available at: http://www.alachisoft.com/resources/docs/#nosdb

Programmers' Guide

The complete programmers guide of NosDB is available at: http://www.alachisoft.com/resources/docs/nosdb/nosdb-programmers-guide.pdf

Technical Support

To request additional features in the future, or if you notice any discrepancy regarding this document, please drop an email to support@alachisoft.com.

License

Licensed under Apache License, Version 2.0. © Copyright 2017 Alachisoft

Readme

Keywords

none

Package Sidebar

Install

npm i nosdb

Weekly Downloads

0

Version

2.0.1

License

Apache-2.0

Last publish

Collaborators

  • ncachedev
  • nosdb