🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

biz9-data-server

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

biz9-data-server

The BiZ9-Data-Server Package is an object-relational mapper (ORM) that lets you build a clean, portable, reusable, and high-level data access layer with Node.js for data driven applications. The package consists of create, read, update and destroy (CRUD)

1.4.9
latest
Source
npm
Version published
Weekly downloads
3
-50%
Maintainers
0
Weekly downloads
 
Created
Source

BiZ9 Data Server

The BiZ9-Data-Server Package is an object-relational mapper (ORM) that lets you build a clean, portable, reusable, and high-level data access layer with Node.js for data driven applications. The package consists of create, read, update and destroy (CRUD) methods to handle data access and manipulations. The framework is fast and used for rapid application development for scaling applications from 0 to millions of records seamlessly and effortless. New data is written and persisted to the MongoDB tables/collections. Fetching data is obtained from the server cache memory using Redis. Using MongoDB with Redis speeds up the overall application tremendously. This framework is used as a [data access component] for mobile and website applications. It is best suited to be used as a package within Express.js. It can also be utilized for other Javascript based applications.

This framework is used as a data access component for mobile and website applications. It is best suited to be used as a package within Express.js. It can also be utilized for other Javascript based applications.

The BiZ9-Data-Server is the ORM solution currently promoted for use with React, React-Native, Angular, and web based projects as a component of the data access stack.

Mongo and Redis Chart

Installation

Use the npm installer to install.

npm i biz9-data-server

Required

  • MongoDB
  • Redis

Contents

Example with Express.js

/*
* Express.JS BiZ9-Service Sample App

* Required
    - $ npm i mocha
    - $ npm i express
    - $ npm i axios

* Test Files
    - app.js = app Express server configuration file.
    - test.js = Mocha test sample.
    - index.js = controller for url

* $> mocha -g 'connect' test.js
*/

// - index.js start - //

let express = require('express');
let router = express.Router();

const { get_db_connect,close_db_connect,update_item,get_item,delete_item } = require("biz9-data-server");

router.get('/connect', function(req, res, next) {
 let db_connect = {};
 let data_config = {
     APP_TITLE_ID:'mongo_database_app_title_id',
     MONGO_IP:"0.0.0.0",
     MONGO_USERNAME_PASSWORD:"",
     MONGO_PORT_ID:"27019",
     MONGO_SERVER_USER:"admin",
     MONGO_CONFIG_FILE_PATH:'/etc/mongod.conf',
     SSH_KEY:"",
     REDIS_URL:"0.0.0.0",
     REDIS_PORT_ID:"27019",
 };
 let item =
     {
         data_type: 'dt_blank',
         id: 0,
         title: 'title_6100',
         first_name: 'first_name_6100',
         last_name: 'last_name_6100',
         user_name: 'user_name_6100',
         test_group_id: 6100
     };
 async.series([
     // get_db_connect
     function(call){
         console.log('BiZ9-Test-Connect');

         get_db_connect(data_config).then(([error,data]) => {
             db_connect = data;
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Connect-Error "+ error);
             call([error,null]);
         });
     },
     // update_item
     function(call){
         console.log('BiZ9-Test-Update-Item');

         let data_type = 'dt_blank';
         let id = 0;

         update_item(db_connect,data_type,item).then(([error,data]) => {
             item = data;
             console.log(data);
             /*
             data = {
                 data_type: 'dt_blank',
                 id: 'f54d788f-9fcb-4def-889f-5b7562741c99',
                 title: 'title_6100',
                 first_name: 'first_name_6100',
                 last_name: 'last_name_6100',
                 user_name: 'user_name_6100',
                 test_group_id: 6100,
                 date_create: '2025-02-10T17:55:31.629Z',
                 date_save: '2025-02-10T17:55:31.632Z',
                 app_title_id: 'mongo_database_app_title_id',
                 source: 'DB'
             }
             */
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Update-Item-Error "+ error);
             call([error,null]);
         });
     },
     // get_item
     function(call){
         console.log('BiZ9-Test-Get');

         let data_type = item.data_type;
         let id = item.id;

         get_item(db_connect,data_type,id).then(([error,data]) => {
             item = data;
             console.log(data);
             /*
                 data = {
                     _id: new ObjectId('67aa3e232d2366b62ef8988a'),
                     data_type: 'dt_blank',
                     id: '34739855-fe74-45f5-a4d1-10f73c98cb88',
                     title: 'title_6100',
                     first_name: 'first_name_6100',
                     last_name: 'last_name_6100',
                     user_name: 'user_name_6100',
                     test_group_id: 6100,
                     date_create: '2025-02-10T17:57:55.024Z',
                     date_save: '2025-02-10T17:57:55.026Z',
                     source: 'DB'
                 }
                 */
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Get-Item-Error "+ error);
             call([error,null]);
         });
     },
     // delete_item
     function(call){
         console.log('BiZ9-Test-Delete');

         let data_type = item.data_type;
         let id = item.id;

         delete_item(db_connect,data_type,id).then(([error,data]) => {
             item = data;
             console.log(data);
             /*
             data = {
                 data_type: 'dt_blank',
                 id: 'ab70a896-5d65-422d-b12f-0c701f2cc95d',
                 cache_del: true,
                 db_del: true
             }
             */
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Delete-Item-Error "+ error);
             call([error,null]);
         });
     },
     // get_item_2
     function(call){
         console.log('BiZ9-Test-Get-2');

         let data_type = item.data_type;
         let id = item.id;

         get_item(db_connect,data_type,id).then(([error,data]) => {
             item = data;
             console.log(data);
             /*
             data = {
                 data_type: 'dt_blank',
                 id: 'a99a3d27-0a87-4fb3-9d5a-7bb66748f0bb',
                 app_title_id: 'mongo_database_app_title_id',
                 source: 'NOT-FOUND'
             }
             */
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Get-Item-2-Error "+ error);
             call([error,null]);
         });
     },
     // close_db_connect
     function(call){
         console.log('BiZ9-Test-Connect');

         close_db_connect(db_connect).then(([error,data]) => {
             call();
         }).catch(error => {
             console.log("Biz9-Connect-Close-Error "+ error);
             call([error,null]);
         });
     },
 ],
     function(err, result){
         res.send({item:item});
         res.end();
     });
});

module.exports = router;
// - index.js end - //

Get DB

Intialize and open Db connection.

Params

  • Data config / DB configuration settings / object
    let data_config = {
        APP_TITLE_ID:'mongo_database_title',
        MONGO_IP:"0.0.0.0",
        MONGO_USERNAME_PASSWORD:"",
        MONGO_PORT_ID:"27019",
        MONGO_SERVER_USER:"admin",
        MONGO_CONFIG_FILE_PATH:'/etc/mongod.conf',
        SSH_KEY:"",
        REDIS_URL:"0.0.0.0",
        REDIS_PORT_ID:"27019",
    };
    

Returns

  • error / Error message / string
  • db_connect / Open client Db connection / object

Example

let db_connect = {};
let data_config = {
    APP_TITLE_ID:'mongo_database_title',
    MONGO_IP:"0.0.0.0",
    MONGO_USERNAME_PASSWORD:"",
    MONGO_PORT_ID:"27019",
    MONGO_SERVER_USER:"admin",
    MONGO_CONFIG_FILE_PATH:'/etc/mongod.conf',
    SSH_KEY:"",
    REDIS_URL:"0.0.0.0",
    REDIS_PORT_ID:"27019",
};

get_db_connect(data_config).then(([error,data]) => {
    db_connect = data;
}).catch(error => {
    console.log(error);
});

close_db_connect

Close Db connection.

Params

  • db_connect / Open client Db connection / object

Returns

  • error / Error message / string
  • db_connect / Closed client Db connection / object

Example

close_db_connect(db_connect).then(([error,data]) => {
}).catch(error => {
    console.log(error);
});

get_item

Get a data item.

Params

  • db_connect / Open client Db connection / object
  • data_type / collection title / string
  • id / ( optional ) / Primary key / GUID

Returns

  • error / Error message / string
  • item / Data item / object

Example

let data_type="dt_blank";
let id="d31facf1-769e-48a6-a7d2-6c349e4b808e";
get_item(db_connect,data_type,id).then(([error,data]) => {
    data = {
        data_type: 'dt_blank',
        id: 'd31facf1-769e-48a6-a7d2-6c349e4b808e',
        title: 'title_450',
        first_name: 'first_name_450',
        last_name: 'last_name_450',
        user_name: 'user_name_450',
        test_group_id: 450,
        date_create: '2025-02-10T02:16:46.137Z',
        date_save: '2025-02-10T02:16:46.138Z',
        app_title_id: 'mongo_database_title',
        source: 'CACHE'
    };
}).catch(error => {
    console.log(error);
});

update_item

Create and or update data item.

Params

  • db_connect / Open client Db connection / object
  • id / Primary key / GUID
  • data_type / collection title / string
  • item / data item / object

Returns

  • error / Error message / string
  • item / Data item / object

Example

let data_type="dt_blank";
let id = 0; // Intialize new data item, id = 0
//let id="9f1aeca3-b466-4cae-af4e-35b3fe9f31a1";  // Get exsisting data item. Guid
let item = {
    id: id,
    data_type:data_type,
    title: 'title_438',
    first_name: 'first_name_438',
    last_name: 'last_name_438',
    user_name: 'user_name_438',
    test_group_id: 438
};
update_item(db_connect,data_type,id,item).then(([error,data]) => {
        data = {
            data_type: 'dt_blank',
            id: '9f1aeca3-b466-4cae-af4e-35b3fe9f31a1',
            title: 'title_438',
            first_name: 'first_name_438',
            last_name: 'last_name_438',
            user_name: 'user_name_438',
            test_group_id: 438,
            date_create: '2025-02-10T02:16:46.137Z',
            date_save: '2025-02-10T02:16:46.138Z',
            app_title_id: 'mongo_database_title',
            source: 'DB'
        }
}).catch(error => {
    console.log(error);
});

delete_item

Delete data item.

Params

  • db_connect / Open client Db connection / object
  • data_type / Collection title / string
  • id / Primary key / GUID

Returns

  • error / Error message / string
  • data / Empty data item. / object

Example

let data_type="dt_blank";
let id="d31facf1-769e-48a6-a7d2-6c349e4b808e";
delete_item(db_connect,data_type,id).then(([error,data]) => {
        data =
        {
            data_type: 'dt_blank',
            id: 'd31facf1-769e-48a6-a7d2-6c349e4b808e',
            cache_del: true,
            db_del: true
        };
}).catch(error => {
    console.log(error);
});

delete_item_list

Delete data items.

Params

  • db_connect / Open client Db connection / object
  • filter_object / Filter / object
  • data_type / Collection title / string

Returns

  • error / Error message / string
  • data / Empty data list / list

Example

let data_type = "dt_blank";
let sql = {data_type:data_type}; //filter field and value
delete_item_list(db_connect,data_type,sql).then(([error,data]) => {
    data = [];
}).catch(error => {
    console.log(error);
});

Credits

Company

  • BiZ9 Framework LLC

Code

E-mail

The BiZ9 Framework 🦾

BiZ9 Framework Logo

The BiZ9 Framework is a developer friendly platform for building premium, polished, fast, professional and scalable business applications using the lastest rapid application development tools and techniques. The framework consists of libraries, commands, scripts, and packages for creating, maintaining, testing, and deploying both mobile and website applications. The primary 3rd party framework used are React, React Native, Node.js, ExpressJS, MongoDB, Nginx, Redis, Git, and Bash. [The BiZ9 Framework] focus is to be precise, routine, rapid, and customizable. The primary target devices for The BiZ9 Framework are Apple iOS, Android, Chrome, Safari, Firefox, and Edge. Other 3rd party Application Programming Interfaces (API) that are pre included are Amazon Web Service, Stripe and Bravely.

TaNK9 Code 👽

Tank9Code Head

Brandon Poole Sr also known as ‘TaNK’ is a technical lead and full stack software engineer with over 19 years of professional experience. He was born and raised in Atlanta, Ga and graduated with a [Computer Information Systems Bachelor of Science Degree] from Fort Valley State University. He is proficient in ASP.NET C#, ASP.NET MVC, .NET Core, Microsoft SQL Server, IIS Web Server, Node.js, React, React Native, Framework7, Redis, Amazon Web Services, Apple iOS, Android SDK, MongoDB, Redis, NGINX, and Git. He has worked as a software developer for Fortune 500 companies such as The Boeing Company, Georgia Pacific, Colonial Pipeline, [Home Depot] and [United Parcel Services].

He is sometimes referred to as “the real Tank” from the movie The Matrix.

TagZ:

#BoSSAppZ
#BiZ9Framework
#EBook
#Mobile
#Apple
#Android
#IOS
#Linux
#AmazonWebServices
#AppMoneyNoteZ
#TaNK9Code
Thank you for your time.
Looking forward to working with you.

License

MIT

Keywords

Nodejs

FAQs

Package last updated on 12 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts