npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datasquirel

v2.0.0

Published

Cloud-based SQL data management tool

Downloads

101

Readme

Datasquirel

This package requires an account with datasquirel, so be sure to create an account at datasquirel-create-account before you continue.

Instalation

$ npm install datasquirel

Once the package is installed, you can import the library using require approach:

const datasquirel = require("datasquirel");

Usage

Fetch Data

This method requires a readonly key or fullaccess API key gotten from datasquirel. It uses a basic https get request paired with some query params.

const datasquirel = require("datasquirel");

const getData = await datasquirel.get({
    key: "aldhkf89asdflksdafh908asdfjkhasdf", // Readonly API Key
    db: "my_database", // Database name slug (Eg. Db Name => My Database, Db Slug => my_database)
    query: "SELECT * FROM blog_posts", // SQL Query
});

Datasquirel uses all conventional SQL query commands. However you can only use the SELECT command when using a readonly API key.

Post Data

This method requires a fullaccess API key gotten from datasquirel. You can perform a basic fetch with this method, as well as more complex operations like UPDATE, DELETE and INSERT.

const datasquirel = require("datasquirel");

const postData = await datasquirel.post({
    key: "aldhkf89asdflksdafh908asdfjkhasdf", // Fullaccess API Key
    payload: {
        action: "insert", // OR "update" OR "delete" OR "select"
        data: {
            user_id: "19aisdn123",
            user_first_name: "John",
            user_last_name: "Doe",
        },
        table: "users",
    },
});

You can simply replace the payload object with an SQL string and it does everything you provide in the SQL command.

const datasquirel = require("datasquirel");

const postData = await datasquirel.post({
    key: process.env.FULL_ACCESS_API_KEY,
    payload: "SELECT * FROM blog_posts WHERE user_id='as09d7nasd90'",
});

You can add a condition to the payload object to filter the results

const datasquirel = require("datasquirel");

const postData = await datasquirel.post({
    key: process.env.FULL_ACCESS_API_KEY,
    payload: {
        action: "delete",
        condition: `WHERE user_id='21adwei9jewr' AND type='buyers'`,
        table: "users",
    },
});

You can use identifierColumnName and identifierValue when updating an entry.

const datasquirel = require("datasquirel");

const postData = await datasquirel.post({
    key: process.env.FULL_ACCESS_API_KEY,
    payload: {
        action: "update",
        table: "users",
        identifierColumnName: "id",
        identifierValue: "21adwei9jewr",
        data: {
            first_name: "Mary",
            last_name: "Spencer",
        },
    },
});

Upload Image

This method requires is similar to the post method, but with different parameters.

const datasquirel = require("datasquirel");

const postData = await datasquirel.uploadImage({
    key: process.env.FULL_ACCESS_API_KEY,
    payload: {
        imageData: "6ejsiua2i29ndsajkfn9n==", // Image in base64
        imageName: `awesome-waterfalls`,
        mimeType: "jpg", // optional
        thumbnailSize: 120, // optional === This measurement is in pixels(px)
    },
});