Skip to content

Large scale architecture for Blitz.js apps #3723

Answered by flybayer
nickluger asked this question in General
Discussion options

You must be logged in to vote

Here's what I have for the store with prisma

import { Project as PrismaProject } from "@prisma/client"
import { db, prismaUtils } from "application/libs/prisma"
import { Project } from "../entities/Project"

const mapper = {
  toEntity(raw: PrismaProject) {
    return Project.new(prismaUtils.clean(raw))
  },
  toPrisma(model: Project) {
    return {
      ...model.data,
      config: prismaUtils.jsonNullable(model.data.config),
    }
  },
}

export const makeProjectStore = (deps = { db }) => ({
  async get({ id, organizationId }: { id: string; organizationId: string | undefined }) {
    const raw = await deps.db.project.findFirst({
      where: { id, organizationId },
    })
    return raw

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@flybayer
Comment options

@flybayer
Comment options

Comment options

You must be logged in to vote
1 reply
@flybayer
Comment options

Comment options

You must be logged in to vote
2 replies
@nickluger
Comment options

@flybayer
Comment options

Answer selected by nickluger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants