Quick ORM
5.2.0
5.2.0
  • Introduction
  • Why Quick?
  • What's New?
  • Upgrade Guide
  • Contributing
  • Guide
    • Getting Started
      • Defining An Entity
        • Subclass Entities
      • Retrieving Entities
      • Working with Entities
      • Creating New Entities
      • Updating Existing Entities
      • Deleting Entities
      • Query Scopes and Subselects
    • Relationships
      • Relationship Types
        • hasOne
        • hasMany
        • belongsTo
        • belongsToMany
        • hasManyThrough
        • hasOneThrough
        • belongsToThrough
        • polymorphicBelongsTo
        • polymorphicHasMany
      • Retrieving Relationships
      • Querying Relationships
      • Relationship Counts
      • Ordering By Relationships
      • Eager Loading
    • CBORM Compatibility Shim
    • Collections
    • Custom Getters & Setters
    • Serialization
    • Interception Points
    • Debugging
    • FAQ
  • Cookbook
    • Introduction
    • Dynamic Datasource
  • External Links
    • API Docs
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page
  • delete
  • deleteAll

Was this helpful?

Edit on GitHub
Export as PDF
  1. Guide
  2. Getting Started

Deleting Entities

delete

You can delete an entity by calling the delete method on it.

var user = getInstance( "User" ).find( 1 );
user.delete();

The entity will still exist in any variables you have stored it in, even though it has been deleted from the database.

deleteAll

Just like updateAll, you can delete many records from the database by specifying a query with constraints and then calling the deleteAll method.

Name

Type

Required

Default

Description

ids

array

false

[]

An optional array of ids to add to the previously configured query. The ids will be added to a WHERE IN statement on the primary key columns.

Deletes matching entities according to the configured query.

getInstance( "User" )
    .whereActive( false )
    .deleteAll();

Additionally, you can pass in an array of ids to deleteAll to delete only those ids. Note that any previously configured constraints will still apply.

getInstance( "User" ).deleteAll( [ 4, 10, 22 ] );
PreviousUpdating Existing EntitiesNextQuery Scopes and Subselects

Last updated 2 years ago

Was this helpful?