Use Oracle
Add Oracle as a database with the @primate/oracle module. Configure it in
config/db; Primate connects to it and provides a unified API.
Ensure Oracle is running and accessible.
$ npm install @primate/oracledb
TypeScriptconfig/db.ts
import oracledb from "@primate/oracledb";
export default oracledb({
host: "localhost",
port: 1521,
database: "FREEPDB1",
// username: "user",
// password: "pass",
});
TypeScriptstores/User.ts
import p from "pema";
import store from "primate/store";
import db from "../config/db.ts";
export default store({
table: "user",
db,
schema: {
id: store.key.primary(p.uuid),
name: p.string,
email: p.string.email(),
},
});
TypeScriptroutes/users.ts
import User from "#store/User";
import route from "primate/route";
export default route({
async get() {
const users = await User.find({});
return users;
},
async post(request) {
const user = await User.insert(await request.body.form());
return user;
},
});