New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

higg-orm

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

higg-orm

basic orm with support for mysql-database

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

higg:orm

Table of contents

  • Introduction
  • Install
  • Querying the database
  • Contributors
  • Todos

Introduction

A basic db/orm system with support for querying mysql-databases for your TypeScript (ES6) application.

Install

Installing the package over npm:

$ npm install higg-orm --save

Querying the database

Simple example for making a select-query on an mysql-database.

Importing the needed modules/classes.

import {DatabaseAdapter, MysqlConnection, MysqlQuerySelect} from '../index';

Defining the connection-details in an simple object.

let connDetails ={
    host: 'your_dbhost',
    user: 'your_username',
    password: 'your_password',
    database: 'your_database'
};

Creating a new adapter for our mysql-database, by simply inject an MysqlConnection into the adapter and defining a name.

let adapter = new DatabaseAdapter(
    new MysqlConnection(connDetails),
    'provider_db'
);

Creating a select-query for the mysql-database and querying the users table with a limit of 1.

let query = new MysqlQuerySelect();
query
    .from('user')
    .limit(1);

Querying the database-adapter with the generated select-object and fetching the result. The query() function of DatabaseAdapter is returning a Promise, since the query is async. So we have to use the .then().catch() syntax for getting the result or the error of the request.

adapter.query(query)
    .then(result => {
        console.log(result);
    })
    .catch(error => {
      console.log('Error querying database: ' + error);
    });

Contributers

If you like to contribute to the package, feel free to fork the repository and make a pull-request. The repository can be found on github

Tests

npm test

Todos

Of course the package is very simple at the moment, there are plenty things to do:

  • writing tests :)
  • writing documentation :)

Keywords

orm

FAQs

Package last updated on 06 Sep 2017

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