Scaffold Collection

Scaffold a new collection file with Lucent boilerplate.

Usage

lucent collection <name>

Arguments

ArgumentDescription
namePascalCase collection name such as Posts or BlogPost

Behavior

The command:

  • writes <Name>.ts into src/collections when that directory exists
  • otherwise falls back to collections
  • creates the directory if needed
  • does not currently support extra flags such as --fields, --auth, or --path

Example

lucent collection Posts

Creates:

import { defineCollection } from "@codesordinatestudio/lucent";

export const Posts = defineCollection({
  slug: "posts",
  fields: [],
  access: {
    read: () => true,
    create: ({ user }) => !!user,
    update: ({ user }) => !!user,
    delete: ({ user }) => user?.role === "admin",
  },
  timestamps: true,
});