Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grook8958/easiermongo
An NPM package used to interact with a MongoDB for beginners.
https://github.com/grook8958/easiermongo
mongo mongodb mongodb-database mongoose nodejs npm-package
Last synced: 15 days ago
JSON representation
An NPM package used to interact with a MongoDB for beginners.
- Host: GitHub
- URL: https://github.com/grook8958/easiermongo
- Owner: grook8958
- License: apache-2.0
- Created: 2022-04-05T10:12:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-08T09:46:57.000Z (about 2 years ago)
- Last Synced: 2024-10-17T10:28:11.663Z (about 1 month ago)
- Topics: mongo, mongodb, mongodb-database, mongoose, nodejs, npm-package
- Language: JavaScript
- Homepage: https://easiermongo.js.org
- Size: 200 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Easiermongo
![Downloads](https://img.shields.io/npm/dt/easiermongo) ![Version](https://img.shields.io/npm/v/easiermongo) ![License](https://img.shields.io/npm/l/easiermongo)
_For additional information please visit our [website](https://easiermongo.js.org)_
## About
Easiermongo is a simple [NodeJS](https://nodejs.org) library for begginers with [MongoDB](http://mongodb.com).
It has a very object-oriented approach which makes your code cleaner and easier to read.
The main goals of this library is not 100% cover the MongoDB API but instead cover in the easiest way possible the basics.## Getting
### Installation
`npm i easiermongo`
### Basic Usage
Open a connection to your database
```js
const { MongoClient } = require('easiermongo');
const client = new MongoClient({ uri: 'your-uri-here' });client.on('ready', () => {
console.log(`Connected to ${client.database.name}!`);
});client.connect();
```There are two ways to register a schema, adding them manually or adding them via the file system.
**Register manually**
```js
const { SchemaBuilder } = require('easiermongo');const mySchema = new SchemaBuilder()
.addField((field) => field.setName('myField').setType('STRING'))
.addField((field) => field.setName('mySecondField').setType('NUMBER').setDefault(0));
//Register your schema
client.database.schemas.addSchema('mySchemaName', mySchema);
```**Register vie File System**
Download [this](https://easiermongo.js.org/examples/getting-started-fs.zip) example.Once connected and your schemas are registered you may start performing actions
```js
const mySchema = client.database.schemas.collection.get('your-schema-name').model;
//You may also get your schema like this: const mySchema = client.database.schemas.SCHEMA_NAME_HERE;
const result = await mySchema.get('some-id');console.log(result);
```Click [here](https://easiermongo.js.org/examples/getting-started.js) to download the first example and click [here](https://easiermongo.js.org/examples/getting-started-fs.zip) for the example using the file system.
## Useful Links
- [Webiste](https://easiermongo.js.org)
- [Documentation](https://easiermongo.js.org/docs/v1/)
- [GitHub](https://github.com/grook8958/easiermongo)
- [npm](https://npmjs.org/package/easiermongo)
- [Mongoose Documentation](https://mongoosejs.com/docs/)