Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

croxydb

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

croxydb

a JSON/YAML/LocalStorage database module

  • 0.0.26
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

CroxyDB

Join our Discord!

Download Download Download License

What's new in 0.0.26?

  • You can now reduce down to - in the "db.subtract" function.

Examples

(QuickDB) Moving Everything to CroxyDB

const db = require("croxydb");
const quickdb = require("quick.db");

await db.move(quickdb)

(JsonDB) Moving Everything to MongoDB

const db = require("croxydb");
db.setAdapter("mongo", {url: "YOUR_MONGO_URL", Schema: "Schema Name"})
const JsonDB = require("../your_file.json");

db.moveToMongo(JsonDB)

Example

const db = require("croxydb")

db.set("x.y.z", "abc") // abc

db.get("x") // {y: {z: "abc"}}
db.fetch("x") // {y: {z: "abc"}}
db.all() // {x: {y: {z: "abc"}}}

db.push("a", "hello") //  ["hello"]
db.push("a", "world") //  ["hello", "world"]
db.unpush("a", "hello") // ["world"]

db.push("b", {test: "croxydb"}) // [{test: "croxydb"}]
db.push("b", {test2: "croxydb2"}) // [{test: "croxydb"}, {test2: "croxydb2"}]
db.delByPriority("b", 1) // [{test2: "croxydb"}]
db.setByPriority("b", {newtest:"hey this is edited"}, 1) // [{newtest:"hey this is edited"}]

db.has("x") // true
db.delete("x") // true
db.deleteAll() // true

MongoDB Support (It is new feature, if you find any bugs join my Discord)

const db = require("croxydb")
db.setAdapter("mongo", 
{
    url: "Your Mongo URL", 
    schema: "Schema Name" // Not required. You can't define your own schema. Just name.
})

await db.set("x.y.z", "abc") // abc

await db.get("x") // {y: {z: "abc"}}
await db.fetch("x") // {y: {z: "abc"}}
await db.all() // {x: {y: {z: "abc"}}}

await db.push("a", "hello") //  ["hello"]
await db.push("a", "world") //  ["hello", "world"]
await db.unpush("a", "hello") // ["world"]

await db.push("b", {test: "croxydb"}) // [{test: "croxydb"}]
await db.push("b", {test2: "croxydb2"}) // [{test: "croxydb"}, {test2: "croxydb2"}]
await db.delByPriority("b", 1) // [{test2: "croxydb"}]
await db.setByPriority("b", {newtest:"hey this is edited"}, 1) // [{newtest:"hey this is edited"}]

await db.has("x") // true
await db.delete("x") // true
await db.deleteAll() // true

Example With Options

const db = require("croxydb")
db.setReadable(true) // It makes readable your JSON DB file.
db.noBlankData(true) // If you delete anything from object and new object size is less than 1, automaticly removes that object.
db.setAdapter("yamldb") // It makes adapter as YAML adapter. Default adapter is JsonDB
db.setFolder("folder") // You can set database folder name
db.setFile("db") // You can set database file name
db.setCheckUpdates(true) // It warns you if any updates happens.

db.set("x.y.z", "abc") // abc

db.get("x") // {y: {z: "abc"}}
db.fetch("x") // {y: {z: "abc"}}
db.all() // {x: {y: {z: "abc"}}}

db.push("a", "hello") //  ["hello"]
db.push("a", "world") //  ["hello", "world"]
db.unpush("a", "hello") // ["world"]

db.push("b", {test: "croxydb"}) // [{test: "croxydb"}]
db.push("b", {test2: "croxydb2"}) // [{test: "croxydb"}, {test2: "croxydb2"}]
db.delByPriority("b", 1) // [{test2: "croxydb"}]
db.setByPriority("b", {newtest:"hey this is edited"}, 1) // [{newtest:"hey this is edited"}]

db.has("x") // true
db.delete("x") // true
db.deleteAll() // true

If you've any question, you can join to my Discord server: Click me!

Keywords

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc