Stone.js API
    Preparing search index...
    • The imperative way to define a resource: an object instead of a class.

      Parity is the rule, so this declares exactly what a class declares and gets exactly what a class gets. It needs nothing injected: this module reads schemas with its own checker.

      Type Parameters

      Parameters

      Returns Resource<Model, Output>

      A resource.

      export const userResource = defineResource<User>({
      schema: z.object({ id: z.number(), name: z.string() }),
      fragments: { summary: z.object({ id: z.number() }) },
      data: async (user) => ({ ...user, posts: await posts.titlesOf(user.id) })
      })