|
| 1 | +# QuickMongo |
| 2 | +Quick mongodb wrapper for beginners. |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +# Documentation |
| 7 | +**[QuickMongo](https://quickmongo.js.org)** |
| 8 | + |
| 9 | +# Features |
| 10 | +- Beginner friendly |
| 11 | +- Easy to use |
| 12 | +- Very similar to **[quick.db](https://npmjs.com/package/quick.db)** |
| 13 | +- Dot notation support |
| 14 | +- Import & export support |
| 15 | +- Key value based |
| 16 | +- Beginner friendly |
| 17 | +- Asynchronous |
| 18 | +- Multiple model support |
| 19 | + |
| 20 | +# Quick Example |
| 21 | + |
| 22 | +```js |
| 23 | +const { Database } = require("quickmongo"); |
| 24 | +const db = new Database("mongodb://localhost/quickmongo"); |
| 25 | + |
| 26 | +db.on("ready", () => { |
| 27 | + console.log("Database connected!"); |
| 28 | +}); |
| 29 | + |
| 30 | +db.set("foo", "bar"); |
| 31 | + |
| 32 | +db.get("foo").then(console.log); |
| 33 | +``` |
| 34 | + |
| 35 | +# Importing data from quick.db |
| 36 | + |
| 37 | +```js |
| 38 | +const db = require("quick.db"); |
| 39 | +const { Database } = require("quickmongo"); |
| 40 | +const mongo = new Database("mongodb://localhost/quickmongo"); |
| 41 | + |
| 42 | +function importData() { |
| 43 | + const data = db.all(); |
| 44 | + mongo.import(data).then(() => { |
| 45 | + console.log("Done!"); |
| 46 | + }); |
| 47 | +} |
| 48 | + |
| 49 | +mongo.on("ready", () => importData()); |
| 50 | +``` |
| 51 | + |
| 52 | +# Links |
| 53 | +- **[Discord Support Server](https://discord.gg/2SUybzb)** |
| 54 | +- **[Documentation](https://quickmongo.js.org)** |
| 55 | +- **[GitHub](https://github.com/Snowflake107/quickmongo)** |
| 56 | + |
| 57 | +# Example |
| 58 | + |
| 59 | +```js |
| 60 | +const { Database } = require("quickmongo"); |
| 61 | +const db = new Database("mongodb://localhost/quickmongo"); |
| 62 | + |
| 63 | +// Setting an object in the database: |
| 64 | +db.set("userInfo", { difficulty: "Easy" }).then(console.log); |
| 65 | +// -> { difficulty: 'Easy' } |
| 66 | + |
| 67 | +db.push("userInfo.items", "Sword").then(console.log); |
| 68 | +// -> { difficulty: 'Easy', items: ['Sword'] } |
| 69 | + |
| 70 | +db.add("userInfo.balance", 500).then(console.log); |
| 71 | +// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 } |
| 72 | + |
| 73 | +// Repeating previous examples: |
| 74 | +db.push("userInfo.items", "Watch").then(console.log); |
| 75 | +// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 } |
| 76 | + |
| 77 | +db.add("userInfo.balance", 500).then(console.log); |
| 78 | +// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 } |
| 79 | + |
| 80 | +// Fetching individual properties |
| 81 | +db.get("userInfo.balance").then(console.log); |
| 82 | +// -> 1000 |
| 83 | +db.get("userInfo.items").then(console.log); |
| 84 | +// -> ['Sword', 'Watch'] |
| 85 | +``` |
0 commit comments