npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@glazk0/lucid-soft-deletes

v1.0.2

Published

Laravel-style soft-delete mixin for AdonisJS Lucid v22

Readme

@glazk0/lucid-soft-deletes

Laravel-style soft-delete mixin for AdonisJS Lucid v22 on AdonisJS v7.

Adds a deletedAt column, a global WHERE deleted_at IS NULL scope, a trashed getter, restore() and forceDelete() instance methods, and withTrashed() / onlyTrashed() / bulk restore() query-builder macros.

This package is a fork of lookinlab/adonis-lucid-soft-deletes, which is no longer actively maintained. The fork brings the mixin forward to AdonisJS v7 + Lucid v22, updates the typings, and ships an Ace command for scaffolding the migration.

Install

node ace add @glazk0/lucid-soft-deletes

This installs the package with your project's package manager and runs the configure hook, which registers the provider in adonisrc.ts, registers the make:soft-delete-migration Ace command, and drops a reference doc under docs/soft_deletes_example.md.

Usage

Apply the mixin

import { DateTime } from 'luxon'
import { compose } from '@adonisjs/core/helpers'
import { BaseModel, column } from '@adonisjs/lucid/orm'
import { SoftDeletes } from '@glazk0/lucid-soft-deletes'

export default class User extends compose(BaseModel, SoftDeletes) {
  @column({ isPrimary: true })
  declare id: number

  @column()
  declare email: string

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  declare updatedAt: DateTime | null
}

Add the deleted_at column

node ace make:soft-delete-migration users
node ace migration:run

The generated migration adds a nullable, indexed deleted_at column. The index is important — the global scope appends WHERE deleted_at IS NULL to every query against the table.

Soft-delete, restore, force-delete

await user.delete()       // soft delete (sets deletedAt)
user.trashed              // true
await user.restore()      // un-delete
await user.forceDelete()  // permanent delete (bypasses soft-delete)

Query helpers

await User.query().withTrashed()                 // includes soft-deleted rows
await User.query().onlyTrashed()                 // returns only soft-deleted rows
await User.query().onlyTrashed().restore()       // bulk restore matching rows

Override the column name

Re-declare deletedAt on your model:

export default class User extends compose(BaseModel, SoftDeletes) {
  @column.dateTime({ columnName: 'removed_at' })
  declare deletedAt: DateTime | null
}

Gotchas

  • Raw queries bypass the scope. db.from('users') is not filtered — same behavior as Laravel.
  • firstOrCreate / updateOrCreate skip soft-deleted rows by default and can create duplicates. Use .withTrashed() lookups for match-or-restore flows.
  • compose() order matters. Put SoftDeletes first after BaseModel so its hooks register before any other mixin's hooks.
  • .clone() drops the scope flag. Explicit query.clone() after withTrashed() loses the opt-out — parity with Laravel.
  • Serialization. deletedAt is serialized by default. To hide it, override with @column.dateTime({ columnName: 'deleted_at', serializeAs: null }).
  • Bulk restore() is gated. Calling restore() on a query builder for a model that lacks the mixin throws ModelNotSoftDeletableException.

License

MIT