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

ant-orm

v1.0.4

Published

A simples, structured and secure indexedDB ORM

Downloads

12

Readme

ANT

Description

It is a small, secure and fast ORM for indexedDB. Created for projects who needed to encapsule their Object Stores into models and a readable API for comunication with the DB.

It is using Web Workers for isolate de access to DB from the default thread. Look at the articles in the bottom of this document and see why it's good to your project.

Instalation

Just run:

$ npm i --save ant-orm

If you aren't using npm and prefer import, junt download in the dist folder the ANT.js file and place into your HTML like this:

<script src="/path/to/ANT.js"></script>

Than you can copy the workers folder and import to your project.

How to build

For building this projet is simples:

$ npm run build

Usage

Initialization

ANT.init({
    databaseName: "DATABASE NAME",
    workersPath: "/path/to/workers",
    version: 1, //version of DB
    modelsPaths: {
        User: "/models/users.js" //Name of your model and path to your model
    }
});

Defining Model

Just create a js file:

class User extends ANT.Model {
    get columns(){
        return this.setColumns({
            id: { type: ANT.TYPES.NUMBER, unique: true },
            name: { type: ANT.TYPES.STRING },
            active: { type: ANT.TYPES.BOOL, defaultValue: true }
        });
    }
}

TYPES

    const number = ANT.TYPES.NUMBER;
    const string = ANT.TYPES.STRING;
    const boolean = ANT.TYPES.BOOL;
    const date = ANT.TYPES.DATE;

Bulk a Model

    let user = new Ant.User({
        id: 1,
        name: "Ricardo Zorzal"
    })

Persisting a Model

    let user = new Ant.User({
        id: 1,
        name: "Ricardo Zorzal"
    });

    await user.persist();

Creating a Model

    let user = await Ant.User.create({
        id: 1,
        name: "Ricardo Zorzal"
    })

Updating a Model

    let user = await Ant.User.create({
        id: 1,
        name: "Ricardo Zorzal"
    });

    user = await user.update({
        name: "Ricardo Zorzal Davila"
    });

Destroying a Model

    let user = await Ant.User.create({
        id: 1,
        name: "Ricardo Zorzal"
    });

    await user.destroy();

Query

Simple Query

    let users = await Ant.User.findAll({
        name: "Ricardo Zorzal"
    });

Operators

    let users = await Ant.User.findAll({
        name: {
            "$eq": "equals",
            "$ne": "not equals",
            "$gt": "greater than",
            "$gte": "greater than equals",
            "$lt": "less than",
            "$lte": "less than equals",
            "$btw": "between",
            "$btwe": "between equals",
            "$in": "IN",
            "$like": "LIKE",
            "$notLike": "NOT LIKE"
        }
    });

Why use Workers instead of default thread

1- http://blog.teamtreehouse.com/using-web-workers-to-speed-up-your-javascript-applications

2- https://developer.mozilla.org/docs/Web/API/Worker

Fast and Secure

Contributions

Please if you have problems, ideias or whatever use the issue board on github. We are always waiting for a new Pull Request.