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

sql-join-to-json

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-join-to-json

Convert 1d sql query results to nested javascript object

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

sql-join-to-json

Convert 1d sql query results to nested javascript object

NPM JavaScript Style Guide

Install

npm

$ npm install --save sql-join-to-json

Getting Started

const sqlJoinToJson = require('sql-join-to-json');

const sqlResults = [
    {
        userName: 'Kusi Musah Hussein',
        age: 24,
        street: 'Fatih',
        apartment: 'CK11',
        phone: '24242424242',
        email: 'eg@email.com'
    },
    {
        userName: 'Kusi Musah Hussein',
        age: 24,
        street: 'Cari',
        apartment: 'YA11',
        phone: '242532535353',
        email: 'eg2@gmail.com'

    }
];

const resultStructure = {
    userName: 1,
    age: 1,
    address: {
        street: 1,
        apartment: 1
    },
    contact: {
        phone: 1,
        email: 1
    }
}

const result = sqlJoinToJson(resultStructure, sqlResults)

console.log(result);

/* 

    Prints

    [
        {
            userName: "Kusi Musah Hussein",
            age: 24,
            address: [
            { street: "Fatih", apartment: "CK11" },
            { street: "Cari", apartment: "YA11" },
            ],
            contact: [
            { phone: "24242424242", email: "eg@email.com" },
            { phone: "242532535353", email: "eg2@gmail.com" },
            ],
        },
];

*/


Pull Requests

Pull requests are welcome

Keywords

sql

FAQs

Package last updated on 25 Nov 2020

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