New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

quickmongo

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quickmongo

Quick mongodb wrapper for beginners.

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
874
decreased by-21.12%
Maintainers
1
Weekly downloads
 
Created
Source

QuickMongo

Quick mongodb wrapper for beginners.

Documentation

QuickMongo

Features

  • Easy
  • Simple
  • Fast
  • Import & export support
  • Key value based

Btw, quick.db users can easily export their data to quickmongo.

Quick Example

const { Database } = require("quickmongo");
const db = new Database("mongodb://localhost/quickmongo");

db.on("ready", () => {
    console.log("Database connected!");
});

db.set("foo", "bar");

db.get("foo").then(console.log);

Exporting data from quick.db to quickmongo

const db = require("quick.db");
const { Database } = require("quickmongo");
const mongo = new Database("mongodb://localhost/quickmongo");

function export() {
    const data = db.all();
    mongo.import(data).then(() => {
        console.log("Successfully exported quick.db data to quickmongo!");
    });    
}

export();

Exporting data from quick.db tables (and custom schema names)

const db = require("quick.db");
const table = new db.table("mytable");

const { Database } = require("quickmongo");
const mongo = new Database("mongodb://localhost/quickmongo", "mytable"); // custom schema name (acts like quickdb table)

function export() {
    const data = table.all();
    mongo.import(data).then(() => {
        console.log("Successfully exported quick.db data to quickmongo!");
    });    
}

export();

Examples

const { Database } = require("quickmongo");
const db = new Database("mongodb://localhost/quickmongo");

// set
db.set("money", 200).then(i => {
    console.log(`Set balance to $${i}`); // 200
});

// add
db.add("money", 100).then(i => {
    console.log(`Added money! now you have $${i}`); // 300
});

// fetch
db.get("money").then(i => {
    console.log(`Your balance: ${i}`); // 300
});

// fetch all
db.all().then(console.log); // [{ ID: "money", data: 300 }]

// delete all
db.deleteAll().then(() => console.log("done!"));

// export your data to json file
db.export("rawdata").then(path => {
    console.log(`Data exported to ${path}...`);
});

// import data from quick.db (listen to "debug" event for details)
db.import(quickdb.all()).then(() => {
    console.log("Data imported!");
});

Value Targets (Path)

Value target (Like key.target of quick.db) support is not yet available in this package. It will be available soon :)

But you can still use it like this:

const { Database } = require("quickmongo");
const db = new Database("mongodb://localhost/quickmongo");

// set data
db.set("user", { items: [] });

// update items
let data = await db.get("user");
data.items = ["keyboard"];
db.set("user", data); // { items: ["keyboard"] }

Keywords

FAQs

Package last updated on 23 Jul 2020

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