Skip to content
On this page

Singleton models

For models that should have one item for each user (e.g. profile) use the the singleton model

typescript
const profile = defineModel({
    schema: {
        name: { type: String },
        email: { type: String },
        bio: { type: String }
    },
    singleton: true // makes the model a singleton
})

This will generate a different set of api routes than a regular model

MethodPathDescription
GET/profileGets the profile
PATCH/profileUpdates the profile

Singleton routes also support setting a custom path.

Released under the MIT License.