This project uses the official MongoDB driver for Node.js. It is a wrapper around the official driver that provides a more convenient API for use with TypeScript and JavaScript.
npm install github:litehex/mongodb#dist
import { MongoDB, InitMongo } from "@litehex/mongodb";
InitMongo({
hostname: "localhost",
port: 27017,
username: "root",
password: "password"
});
export const db = MongoDB.db("testing");
import { OptionalId, CollectionConfig } from "@litehex/mongodb";
import Collection from "@litehex/mongodb/collection";
export type User = OptionalId<{
nickname: string;
email: string;
}>
export class UsersCollection extends Collection<User> {
getConfig(): CollectionConfig {
return {
name: "users",
database: "testing"
}
}
static doSomething() {
console.log("Something");
}
}
This project is licensed under the MIT license. See the LICENSE file for more info.