-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a718b03
commit 70ab023
Showing
7 changed files
with
92 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## To update schemas | ||
|
||
1. modify schema.prisma | ||
|
||
## After changing schema | ||
|
||
1. Prisma Generate using `npx prisma generate` [OPTIONAL] | ||
2. Prisma Migrate `npx prisma migrate dev --name <migration-name>` | ||
3. | ||
|
||
### .env file | ||
|
||
```bash | ||
DATABASE_URL="file:./dev.db" | ||
``` | ||
|
||
### Testing | ||
|
||
0. Modify the sample.ts file for testing | ||
1. Run `npm run build | ||
2. Run `node dist/sample.js` | ||
3. If needed modify services |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
import { db } from "../lib/prisma.js"; | ||
|
||
export async function getBrands(offset = 0, limit = 10) { | ||
const brands = await db.domains.findMany({ | ||
skip: offset, | ||
take: limit, | ||
}) | ||
return brands; | ||
const brands = await db.domains.findMany({ | ||
skip: offset, | ||
take: limit, | ||
}); | ||
return brands; | ||
} | ||
|
||
export async function getBrand(id: string) { | ||
const brand = await db.domains.findUnique({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
return brand; | ||
export async function getBrand(id: number) { | ||
const brand = await db.domains.findUnique({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
return brand; | ||
} | ||
|
||
export async function getBrandByQuery(query: any) { | ||
const brand = await db.domains.findUnique({ | ||
where: { | ||
...query, | ||
}, | ||
}); | ||
return brand; | ||
const brand = await db.domains.findUnique({ | ||
where: { | ||
...query, | ||
}, | ||
}); | ||
return brand; | ||
} | ||
|
||
export async function deleteBrand(id: string) { | ||
const brand = await db.domains.delete({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
return brand; | ||
export async function deleteBrand(id: number) { | ||
const brand = await db.domains.delete({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
return brand; | ||
} | ||
|
||
export async function updateBrand(id: string, data: any) { | ||
const brand = await db.domains.update({ | ||
where: { | ||
id, | ||
}, | ||
data, | ||
}); | ||
return brand; | ||
export async function updateBrand(id: number, data: any) { | ||
const brand = await db.domains.update({ | ||
where: { | ||
id, | ||
}, | ||
data, | ||
}); | ||
return brand; | ||
} | ||
|
||
export async function createBrand(data: any) { | ||
const brand = await db.domains.create({ data }); | ||
return brand; | ||
} | ||
const brand = await db.domains.create({ data }); | ||
return brand; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters