https://github.com/fadhilsaheer/mongoi
Node js module for dealing with mongo db ๐
https://github.com/fadhilsaheer/mongoi
database javascript mongodb nodejs
Last synced: 2 months ago
JSON representation
Node js module for dealing with mongo db ๐
- Host: GitHub
- URL: https://github.com/fadhilsaheer/mongoi
- Owner: fadhilsaheer
- License: mit
- Created: 2020-12-24T09:04:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-24T09:44:45.000Z (over 5 years ago)
- Last Synced: 2025-08-27T01:05:59.201Z (10 months ago)
- Topics: database, javascript, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# MONGOI๐
MONGOI is a npm package made by Fadhil
easy tool to manage and do CRUD operation with mongo database
### Setup
Requirements
- Node Js
- Npm
- Mongo Db
- Internet [to download] ๐
```
npm i mongoi
```
This will install mongoi for you ๐
### How To Use
Mongoi will help you to do crud operation ๐ฑ
to have more features don't forget to contribute ๐
After installing require it
```javascript
const mongoi = require('mongoi')
```
you have initialize it first
```javascript
let yourDatabaseConnectionUrl = "mongodb://localhost:27017/[you-db-name]"
// create database schema as you do for mongoose
let databaseSchema = {
name: String,
}
let collectionName = "your-collection-name"
mongoi.init(yourDatabaseConnectionUrl, databaseSchema, collectionName).then(()=>{
// you can write anything here except bug ๐
})
```
now you initialized mongoi successfully ๐
so lets start doing crud ๐
CRUD = CREATE - READ - UPDATE - DELETE
```javascript
// This is the model of crud ๐ช
mongoi.crud([option], data).then(()=>{
// use it ๐
})
// options
// [you have to write it in string eg : "r"]
//
// s - "save"
// r = "read"
// ro = "read one"
// u = "update many"
// uo = "update one"
// d = "delete all"
// do = "delete one"
// dm = "delete many"
//
// Enjoy ๐ค
//
```
#### Create
lets create ๐ป
```javascript
// create this according to you schema
const data_to_save = {
name: "apple",
color: "red"
}
mongoi.crud("s", data_to_save) // you can call .then after this ๐ฅฑ
```
#### Read
lets read ๐
```javascript
// read all
mongoi.crud("r").then((data_you_get_from_database)=>{
// do with this data ๐ผ
})
```
```javascript
// read one
let condition = {name: "panda"} // this is the condition of what are you looking for
mongoi.crud("ro", condition).then((data_you_get_from_database)=>{
// do with this data ๐ง
})
```
#### Update
let update ๐
```javascript
// update many or update all
let condition_and_data = [
{cute_message: "you are ugly ๐คฎ"},//this should be condition
{cute_message: "you are cute ๐"}//thing you wan't to change
]
mongoi.crud("u", condition_and_data)// you can call .then after this ๐ฅฑ i don't care ๐
// ๐
/*
let condition_and_data = [
{cute_message: "you are cute ๐"},//you are not cute ๐
{cute_message: "you are ugly ๐คฎ"}//you are ugly ๐
]
mongoi.crud("u", condition_and_data)// just kidding ๐
*/
```
```javascript
// update one
let condition_and_data = [
{cute_message: "you are ugly ๐คฎ"},//this should be condition
{cute_message: "you are cute ๐"}//thing you wan't to change
]
mongoi.crud("uo", condition_and_data)// you can call .then after this ๐ฅฑ i don't care ๐
// ๐
/*
let condition_and_data = [
{cute_message: "you are cute ๐"},//you are not cute ๐
{cute_message: "you are ugly ๐คฎ"}//you are ugly ๐
]
mongoi.crud("u", condition_and_data)// just kidding ๐
```
#### Delete
lets delete this ๐งบ
```javascript
// delete all
mongoi.crud("d") // .then is supported ๐
```
```javascript
// delete many
let condition = {cute_message: "you are cute"}
mongoi.crud("dm", condition)// use .then if you want
```
```javascript
// delete one
let condition = {cute_message: "you are cute"}
mongoi.crud("do", condition)// use .then if you want no one cares ๐
```
## Conclusion
Hopefully I assume that you love ๐ this
contribute for updating this garbage ๐
๐จโ๐ป With ๐ Fadhil