Database Configuration
Configure your database connection for the ORM.
SQLite Configuration
Configure SQLite database connection:
import { setOrmConfig } from "@bunary/orm";
// SQLite
setOrmConfig({
database: {
type: "sqlite",
sqlite: {
path: "./database.sqlite"
}
}
});
MySQL Configuration
MySQL support is coming soon:
// MySQL (coming soon)
// setOrmConfig({
// database: {
// type: "mysql",
// mysql: {
// host: "localhost",
// port: 3306,
// user: "root",
// password: "password",
// database: "myapp"
// }
// }
// });
Best Practices
- Use BaseModel for type safety: Extend
BaseModelinstead of usingModel.table()directly - Protect sensitive fields: Always add sensitive fields to the
protectedarray - Use timestamps: Enable timestamps for automatic
createdAt/updatedAttracking - Chain queries: Use the fluent query builder for readable, maintainable code