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 🙏

© 2026 – Pkg Stats / Ryan Hefner

batchjs-data

v1.1.1

Published

Extension for BatchJS adding data storage support for databases

Readme

GitHub license Latest release NPM Badge CI Coverage Funding

BatchJS-Data

Extension of Batch JS adding data storage support for databases.



Download

Latest release

NPM

NPM Badge

npm install batchjs-data --no-optional
npm install sqlite sqlite3  #For SQLite implementation
npm install mariadb         #For MariaDB implementation
npm install mysql2          #For MySQL implementation
npm install pg @types/pg    #For PostgreSQL implementation

Yarn

yarn add batchjs-data --no-optional
yarn add mariadb         #For MariaDB implementation
yarn add mysql2          #For MySQL implementation
yarn add pg @types/pg    #For PostgreSQL implementation
yarn add sqlite sqlite3  #For SQLite implementation

Usage

  1. Create your reader
    import sqlite3 from "sqlite3";
    import  {open} from "sqlite";
    import { SqliteBatchEntityReader } from "batchjs-data/sqlite";
    import { UserDTO } from "./UserDTO";
    
    export class UserBatchReader extends SqliteBatchEntityReader<UserDTO,UserDTO> {
        constructor(options:{batchSize:number,query?:string}) {
            super({
                batchSize: options.batchSize,
                dbConnectionFactory: () => { return open({filename: './database.db', driver: sqlite3.Database});},
                query: options.query || "SELECT id, username FROM users",
                rowToEntity: (row: UserDTO) => row
            });
        }
    }
  2. Create your writer
    import sqlite3 from "sqlite3";
    import sqlite, {open} from "sqlite";
    import { SqliteBatchEntityWriter } from "batchjs-data/sqlite";
    import { UserDTO } from "./UserDTO";
    
    export class UserBatchWriter extends SqliteBatchEntityWriter<UserDTO> {
        constructor(options:{batchSize:number}){
            super({
                batchSize: options.batchSize,
                dbConnectionFactory: () => { return open({filename: './database.db', driver: sqlite3.Database});},
                prepareStatement: "INSERT INTO users (id, username) VALUES (@id, @username)",
                saveEntity:(entity: UserDTO, stmt: sqlite.Statement)=>stmt.all<void>({'@id': entity.id, '@username': entity.username})
            });
        }
    }
  3. Use them in your BatchJS Job
    import { Job, Step } from "batchjs";
    
    // Implement a step
    class StepImplementation extends Step {
        // Set a name to the step
        constructor(name: string = "DemoStep") {
            super(name);
        }
    
        // Implement the reader to load step data source
        protected _reader() {
            return new UserBatchReader({batchSize:2});
        }
    
        // Implement the processors to transform data sequently using our streams or your own streams
        protected _processors() {
            const opts: TransformOptions = {
                objectMode: true,
                transform(
                    chunk: unknown,
                    encoding: BufferEncoding,
                    callback: TransformCallback
                ) {
                    this.push(chunk);
                    callback();
                },
            };
            return [new Transform(opts), new Transform(opts)];
        }
    
        // Implement the write to stock final step data
        protected _writer() {
            return new UserBatchWriter({batchSize:2})
        }
    }
    
    // Implement a Job
    class JobImplementation extends Job {
        // Implement to set the steps to be sequently executed.
        protected _steps() {
            return [new StepImplementation(), new StepImplementation()];
        }
    }
    
    // Instance the Job
    const job = new JobImplementation("My job");
    
    // Set events listener
    job.on("stepStart", (step: step) => {
        console.log(`Starting step ${step.name}`);
    });
    
    // Launch the job
    job.run()
        .then(() => {
            console.log("Job completed successfully");
        })
        .catch((error) => {
            console.log("Job completed with errors");
        });

Documentation

Collaborators welcome!

GitHub Contributors

Subscribe our code of conduct and follow the Contribution Guidelines.