Skip to content

Commit

Permalink
Merge pull request #77 from koyopro/feature/examples
Browse files Browse the repository at this point in the history
Update examples
  • Loading branch information
koyopro authored Dec 3, 2024
2 parents d8d0601 + a9bceb1 commit be940e3
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 216 deletions.
63 changes: 38 additions & 25 deletions examples/basics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions examples/basics/src/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { initAccelRecord } from "accel-record";
import { Accel } from "accella";
import { getDatabaseConfig } from "../models";

export const setupDatabase = async () => {
const sqlitePath = Accel.root.child(
"./db/schema/",
import.meta.env.DATABASE_URL.replace("file:", "")
);
await initAccelRecord({
type: "sqlite",
datasourceUrl: sqlitePath.toString(),
});
await initAccelRecord(getDatabaseConfig());
};
41 changes: 41 additions & 0 deletions examples/basics/src/models/_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable */
/***************************************************************
* This file is automatically generated. Please do not modify.
***************************************************************/

import { type DataSource } from "@prisma/generator-helper";

import {
generateDatabaseConfig,
registerModel,
type Collection,
type Filter,
type StringFilter,
} from "accel-record";
import { Attribute, defineEnumTextAttribute } from "accel-record/enums";

declare module "accel-record" {
function meta<T>(model: T): Meta<T>;

interface Relation<T, M> {}
}

type Meta<T> = any;

export const schemaDir = "../../../db";
export const dataSource = {
name: "db",
provider: "sqlite",
activeProvider: "sqlite",
url: {
fromEnvVar: "DATABASE_URL",
value: null,
},
schemas: [],
} as DataSource;

/**
* Retrieves the database connection settings based on the Prisma schema file.
*/
export const getDatabaseConfig = () =>
generateDatabaseConfig(dataSource, import.meta.url, schemaDir);
5 changes: 5 additions & 0 deletions examples/basics/src/models/applicationRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Model } from "accel-record";

export class ApplicationRecord extends Model {
// Implement methods
}
1 change: 1 addition & 0 deletions examples/basics/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./_types.js";
Loading

0 comments on commit be940e3

Please sign in to comment.