ent-framework
  • Ent Framework
  • Getting Started
    • Code Structure
    • Connect to a Database
    • Create Ent Classes
    • VC: Viewer Context and Principal
    • Ent API: insert*()
    • Built-in Field Types
    • Ent API: load*() by ID
    • N+1 Selects Solution
    • Automatic Batching Examples
    • Ent API: select() by Expression
    • Ent API: loadBy*() Unique Key
    • Ent API: update*()
    • Ent API: deleteOriginal()
    • Ent API: count() by Expression
    • Ent API: exists() by Expression
    • Ent API: selectBy() Unique Key Prefix
    • Ent API: upsert*()
    • Privacy Rules
    • Validators
    • Triggers
    • Custom Field Types
  • Ent API: Configuration and Types
  • Scalability
    • Replication and Automatic Lag Tracking
    • Sharding and Microsharding
    • Sharding Terminology
    • Locating a Shard and ID Format
    • Sharding Low-Level API
    • Shard Affinity and Ent Colocation
    • Inverses and Cross Shard Foreign Keys
    • Shards Rebalancing and pg-microsharding Tool
    • Connection Pooling
  • Advanced
    • Database Migrations and pg-mig Tool
    • Ephemeral (Symbol) Fields
    • Atomic Updates and CAS
    • Custom Field Refactoring
    • VC Flavors
    • Query Cache and VC Caches
    • Loaders and Custom Batching
    • PostgreSQL Specific Features
    • Query Planner Hints
    • Cluster Maintenance Queries
    • Logging and Diagnostic Tools
    • Composite Primary Keys
    • Passwords Rotation
  • Architecture
    • Abstraction Layers
    • Ent Framework, Meta’s TAO, entgo
    • JIT in SQL Queries Batching
    • To JOIN or not to JOIN
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Getting Started

Ent API: deleteOriginal()

Similar to update*() calls, deleteOriginal() is a method of Ent instance.

ent.deleteOriginal(): boolean

Deletes a row in the database whose ID equals to ent.id. Returns true if the object was found.

Before deleting the row, deleteOriginal() runs all privacy checks defined in the Ent class configuration, making sure ent.vc has permissions to delete the Ent. In case there are no privacy checks defined for deletion (no privacyDelete), uses privacyUpdate rules for the verification, and if it's also undefined, delegates to privacyInsert.

Since all Ent instances are immutable, the call keeps the current Ent instance unchanged. This is why it's called deleteOriginal() and not just delete() — because it's basically a mutation of the source.

And yes, to delete an Ent, you first need to load it (using e.g. loadX(), select() or any other call). Also, there is intentionally no way to delete Ents in bulk: you can only delete a single Ent (concurrent deletion calls are batched into one SQL query as usual though, so it's efficient).

PreviousEnt API: update*()NextEnt API: count() by Expression

Last updated 5 months ago

Was this helpful?