2.1.0 • Published 3 years ago

ezpz.db v2.1.0

Weekly downloads
6
License
ISC
Repository
-
Last release
3 years ago

ezpz.db

A package to make using mongodb easier and user friendly!

Install ✨

npm install ezpz.db

Usage 💻

const db = require('ezpz.db');

db.connect('mongodb://localhost/my_database', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false,
  useCreateIndex: true
}) //same as mongoose's connect function

Main methods

/*--------------------Adding a data to an id--------------------*/
  db.set("player", {wallet: 500})
  // "player" is the id
  // {wallet: 500} is the data

  db.get("player").then(p => {
  // `wallet` will be false if `db.get()` cant find the document
    if (!p) return console.log(0) // -> 0
    console.log(p.wallet) // -> 500 
  })
/*--------------------------------------------------------------*/
/*---------------------Deleting a data---------------------*/
  db.delete("player")
  db.get("player").then(p => console.log(p)) // -> false
/*---------------------------------------------------------*/

Dynamic methods

/*--------------------------------Get all data from collection--------------------------------*/
  // Lets add a new object first
  db.set("player2", {wallet: 100, items: ["bow","arrows"]})
  // the `all()` function is a promise that returns an array
  db.all().then(all => console.log(all))
  /*
      [
        {id: "player", {data: {wallet: 500}}},
        {id: "player2", {data: {wallet: 100, items: ["bow", "arrows"]}}},
      ]
  */
/*--------------------------------------------------------------------------------------------*/
/*----Delete everythng in the collection----*/
  db.empty()
  db.all().then(all => console.log(all))
  // -> []
/*------------------------------------------*/

Have an issue? 🚨

Let me know in my discord server

2.0.7

3 years ago

2.0.6

3 years ago

2.1.0

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.13

3 years ago

1.1.1

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.0.185

3 years ago

1.1.0

3 years ago

1.0.184

3 years ago

1.0.183

3 years ago

1.0.182

3 years ago

1.0.181

3 years ago

1.0.180

3 years ago

1.0.179

3 years ago

1.0.178

3 years ago

1.0.176

3 years ago

1.0.177

3 years ago

1.0.175

3 years ago

1.0.174

3 years ago

1.0.173

3 years ago

1.0.172

3 years ago

1.0.171

3 years ago

1.0.169

3 years ago

1.0.170

3 years ago

1.0.168

3 years ago

1.0.167

3 years ago

1.0.165

3 years ago

1.0.166

3 years ago

1.0.164

3 years ago

1.0.163

3 years ago

1.0.162

3 years ago

1.0.161

3 years ago

1.0.160

3 years ago

1.0.159

3 years ago

1.0.158

3 years ago

1.0.157

3 years ago

1.0.156

3 years ago

1.0.155

3 years ago

1.0.154

3 years ago

1.0.153

3 years ago

1.0.152

3 years ago

1.0.151

3 years ago

1.0.150

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.141

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.1

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

0.0.12

3 years ago

0.0.1

3 years ago

1.0.0

3 years ago