A lightweight ORM for interacting with JSON Bin as a database. This library simplifies CRUD operations on JSON Bin, allowing you to treat it like a regular database.
- Easy setup and configuration
- CRUD operations (Create, Read, Update, Delete)
- Schema validation for data integrity
- Lightweight and fast
Install the package using npm:
npm install jsonbin-ormImport the library and initialize a bin instance:
const { bin } = require("jsonbin-orm");
const myBin = new bin({
binId: "your-bin-id",
apiKey: "your-api-key",
schema: {
"name": "string",
"age": "number"
}
});const newRecord = await myBin.createNew({
name: "Alice",
age: 25
});
console.log(newRecord);const record = await myBin.fetchById("record-id");
console.log(record);const updatedRecord = await myBin.updateOneById("record-id", {
name: "Bob",
age: 30
});
console.log(updatedRecord);const result = await myBin.deleteById("record-id");
console.log(result);const records = await myBin.find({ name: "Alice" });
console.log(records);const updatedRecords = await myBin.updateMany({ age: 25 }, { age: 26 });
console.log(updatedRecords);binId: The ID of your JSON Bin.apiKey: Your JSON Bin API key.schema: An object defining the expected structure of your data.
This project is licensed under the GPL v3 License. See the LICENSE file for details.
Explore supported schema types and samples in the schema types file.
Feel free to open issues or submit pull requests to improve the library.