Ryder Gembootan is a Simple Query Builder For Javascript.
- support chaining query like eloquent in laravel
- easy to use
Database | Status |
---|---|
MongoDB | ✅ Supported |
MySQL | 🚧 Ongoing |
PostgreSQL | 🚧 Ongoing |
SQLite | ✅ Supported |
npm install ryder-gembootan
Or installing with yarn? yarn add ryder-gembootan
First you need to create model first and extends RyderGembootan model
// UserModel.js
import RyderGembootan from "ryder-gembootan";
export default class UserModel extends RyderGembootan.MongoModel {
constructor() {
super(
"MONGODB_USER",
"MONGODB_PASS",
"MONGODB_HOST",
"MONGODB_DBNAME",
"MONGODB_COLLNAME"
);
}
}
After then you can use this model to do a query into your database easily
// index.js
import UserModel from "./UserModel.js";
const main = async () => {
// initialize model object
const model = new UserModel();
// get all data
const result = await model.get();
console.log("result", result);
};
main();
to get data you can use first()
, find()
, or get()
// get all data
await model.get();
// get first record
await model.first();
// get data by id
await model.find("15198465465138");
get all data from database where email = [email protected]
await model.where("email", "=", "[email protected]").get();
get first data from database where email = [email protected]
await model.where("email", "=", "[email protected]").first();
insert into database with data name: angger, and email: [email protected]
await model.create({
name: "angger",
email: "[email protected]",
});
update data, set name = angger priyardhan, where email = [email protected]
await model.where("email", "=", "[email protected]").update({
name: "angger priyardhan",
});
delete from database where email = [email protected]
await model.where("email", "=", "[email protected]").delete();