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

@croosdb/crossdb-nodejs

v1.4.1

Published

CroosDB Nodejs driver

Readme

NodeJS Driver for CrossDB

Pre-requirement

You need to install crossdb lib first

Install

  npm install @croosdb/crossdb-nodejs

Use

  const CrossDB = require('@croosdb/crossdb-nodejs');

  const db = new CrossDB(':memory:');
// or
  const db = new CrossDB('./<<path>>/<<db name>>');

Contributors

Example

// Import the CrossDB module
const CrossDB = require('@croosdb/crossdb-nodejs');

// Create an in-memory database instance
const db = new CrossDB(':memory:');

try {
    // Create tables if they do not already exist
    db.exec("CREATE TABLE IF NOT EXISTS student (id INT PRIMARY KEY, name CHAR(16), age INT, class CHAR(16), score FLOAT, info VARCHAR(255))");
    db.exec("CREATE TABLE IF NOT EXISTS teacher (id INT PRIMARY KEY, name CHAR(16), age INT, info CHAR(255), INDEX (name))");
    db.exec("CREATE TABLE IF NOT EXISTS book (id INT PRIMARY KEY, name CHAR(64), author CHAR(32), count INT, INDEX (name))");
    console.log("Tables 'student','teacher' and 'book' created.");

    // Clean (empty) all tables
    db.exec("DELETE FROM student");
    db.exec("DELETE FROM teacher");
    db.exec("DELETE FROM book");

    // Start a transaction
    db.begin();
    console.log("Begin transaction");

    // Insert sample data into the student, teacher, and book tables
    db.exec("INSERT INTO student (id,name,age,class,score) VALUES (1,'jack',10,'3-1',90),(2,'tom',11,'2-5',91),(3,'jack',11,'1-6',92),(4,'rose',10,'4-2',90),(5,'tim',10,'3-1',95)");
    db.exec("INSERT INTO student (id,name,age,class,score,info) VALUES (6,'Tony',10,'3-1',95,'%s')", "He is a boy.\nHe likes playing football.\nWe all like him!");
    db.exec("INSERT INTO student (id,name,age,class,score,info) VALUES (7,'Wendy',10,'3-1',95,'%s')", "She is a girl.\nShe likes cooking.\nWe all love her!");
    db.exec("INSERT INTO teacher (id,name,age) VALUES (1,'Tomas',40),(2,'Steven',50),(3,'Bill',31),(4,'Lucy',29)");
    db.exec("INSERT INTO book (id,name,author,count) VALUES (1,'Romeo and Juliet','Shakespeare',10),(2,'Pride and Prejudice','Austen',5),(3,'Great Expectations','Dickens',8),(4,'Sorrows of Young Werther','Von Goethe',4)");
    console.log("Data inserted.");

    // Query to select all students
    let res = db.exec("SELECT * FROM student");
    res.forEach((element,i) => {
        console.log(i,"Select all students: ", element);
    });

    // Update a student's age and query the updated record
    db.exec("UPDATE student set age=9 WHERE id = 2");
    console.log("Updated age to 9 for student with id = 2");

    res = db.exec("SELECT id,name,age,class,score from student WHERE id = 2");
    res.forEach((element,i) => {
        console.log(i,"Select student with id = 2: ", element);
    });

    // Delete a student and query the deleted record
    db.exec("DELETE FROM student WHERE id = 3");
    console.log("Deleted student with id = 3");

    res = db.exec("SELECT * from student WHERE id = 3");
    res.forEach((element,i) => {
        console.log(i,"Select student with id = 3: ", element);
    });

    // Perform aggregation on the student table
    res = db.exec("SELECT COUNT(*),MIN(score),MAX(score),SUM(score),AVG(score) FROM student");
    res.forEach((element,i) => {
        console.log(i,"Student aggregation (COUNT, MIN, MAX, SUM, AVG): ", element);
    });

    // Commit the transaction
    db.commit();
    console.log("Transaction committed");

    // Start a new transaction
    db.begin();
    console.log("Begin transaction");

    // Update a student's age, query, and roll back the transaction
    db.exec("UPDATE student set age=15 WHERE id = 2");
    console.log("Updated age to 15 for student with id = 2");

    res = db.exec("SELECT id,name,age,class,score from student WHERE id = 2");
    res.forEach((element,i) => {
        console.log(i,"Select student with id = 2: ", element);
    });

    db.rollback();
    console.log("Transaction rolled back");

    res = db.exec("SELECT id,name,age,class,score from student WHERE id = 2");
    res.forEach((element,i) => {
        console.log(i,"Select student with id = 2 after rollback: ", element);
    });

    // Execute multiple statements and query the results
    res = db.exec("SELECT COUNT(*) as Count FROM student; SELECT id, name, age FROM student WHERE id=2;SELECT MIN(score) as min, MAX(score) as max, SUM(score) as sum, AVG(score) as avg FROM student");
    res.forEach((element,i) => {
        console.log(i,"Multi-statement select: ", element);
    });

} catch (err) {
    // Handle errors, roll back any pending transaction, and log the error
    console.error("Error during operation:", err);
    db.rollback();
    console.log("Transaction rolled back due to error");
} finally {
    // Ensure the database connection is closed
    console.log("\nCrossDB Simulation Complete.");
    db.close();
    console.log("Database connection closed.");
    const version = db.version()
    console.log("CroosDB version: ", version);
}