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

opsqlite

v1.0.0

Published

it's very powerful and useful db as it have so many advaced fetures

Downloads

4

Readme

Author

Sanikava

Support Server -> https://discord.link/sanikava

Examples

Getting Started

const { OP } = require("opsqlite");
const db = new OP("./data/storage.db", { path: "./data", table: "ROOT" }); 

// add some data
db.set("foo", "bar");
db.set("hello", "world");

// see data which is added before
console.log(db.get("foo"))
console.log(db.get("hello"))

// read all data in database
console.log(db.all)

#Simple Usages

db.all(options)

This method returns currently used table (or specified table) as array.

db.fetchAll(options)

Alias of db.all().

db.add(key, number, options)

This method can be used for addition (numbers).

db.delete(key, options)

This method can be used to remove specific data with its key.

db.fetch(key, options)

This method can be used to get data from the database.

db.get(key, options)

Alias of db.fetch.

db.set(key, value, options)

This method can be used to update existing data or add new data.

db.subtract(key, number, options)

Similar to db.add, this method can be used for subtraction.

db.has(key, options)

Returns true if it finds the requested key in the database.

db.type(key, options)

Returns data type of the value assigned to this key.

db.push(key, valueOrValues)

This method can be used to push the data (Similar to Array.prototype.push).

db.pull(key, itemOrItems, options)

Used to pull data from the array stored inside the database. (Reverse .push)

Advanced usage

Methods

db.find(fn, options)

Similar to Array.prototype.find.

db.some(fn, options)

Similar to Array.prototype.some.

db.map(fn, options)

Similar to Array.prototype.map.

db.flatMap(fn, options)

Similar to Array.prototype.flatMap.

db.forEach(fn, options)

Similar to Array.prototype.forEach.

db.every(fn, options)

Similar to Array.prototype.every.

db.findIndex(fn, options)

Similar to Array.prototype.findIndex.

db.indexOf(searchElement, fromIndex)

Similar to Array.prototype.indexOf.

db.reduce(fn, options)

Similar to Array.prototype.reduce.

db.reduceRight(fn, options)

Similar to Array.prototype.reduceRight.

db.sort(fn, options)

Similar to Array.prototype.sort.

db.tables()

Returns all table name.

db.createTable(name)

If not available, creates a new table with the given name otherwise uses existing table and returns new database with that table as root table.

db.drop(options)

Drops current table or specified table.

db.keyArray(options)

Returns array of keys.

db.valueArray(options)

Returns array of values.

db.array()

Returns array of this table.

db.divide(key, number, options)

Division for existing data with the given number.

db.multiply(key, number, options)

Multiplication for existing data with the given number.

db.modulus(key, number, options)

Modulus for existing data with the given number.

db.startsWith(key, options)

Similar to db.all but easier method to sort by key.

db.endsWith(key, options)

Similar to db.all but easier method to sort by key.

db.deleteAll(options)

Deletes all data from the specified table.

db.size()

File size of this db.

db.eval(x)

Allows you to evaluate anything inside Database class using this.

db.prepareTable(name)

A method that just creates table rather than returning new database.

db.export(options)

Exports database into json data.

db.use(database)

This method updates current database manager with a new one. Database parameter can either be Database instance or BetterSQLite3.Database instance.

db.allTableArray()

Returns array of all tables with their table name.

db.flat()

This method is similar to db.allTableArray but returns whole data as single array (like db.all).

Properties

db.database

Current database manager.

db.rowCount

Number of rows in this table.

db.path

Database path.

db.name

Database file name.

db.tableName

Root table name used while instantiating this database.

db.length

Alias of db.rowCount.