1.0.1-beta.16 • Published 2 years ago

easiermongo v1.0.1-beta.16

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Easiermongo

Downloads Version License

For additional information please visit our website

About

Easiermongo is a simple NodeJS library for begginers with MongoDB. 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

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

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 example.

Once connected and your schemas are registered you may start performing actions

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 to download the first example and click here for the example using the file system.

Useful Links

1.0.1-beta.16

2 years ago

1.0.1-beta.14

2 years ago

1.0.1-beta.15

2 years ago

1.0.1-beta.13

2 years ago

1.0.1-beta.12

2 years ago

1.0.1-beta.11

2 years ago

1.0.1-beta.10

2 years ago

1.0.1-beta.9

2 years ago

1.0.1-beta.8

2 years ago

1.0.1-beta.7

2 years ago

1.0.1-beta.6

2 years ago

1.0.1-beta.5

2 years ago

1.0.1-beta.4

2 years ago

1.0.1-beta.3

2 years ago

1.0.1-beta.2

2 years ago

1.0.1-beta.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago