payload icon indicating copy to clipboard operation
payload copied to clipboard

feat: collections can use custom database operations

Open kendelljoseph opened this issue 1 year ago • 0 comments

Description

Adds option to override default database operations for a collection

import { CollectionConfig } from 'payload/types';

const Collection: CollectionConfig = {
  slug: 'example-collection',
  // Database operations for this collection  
  db: {
    create: () => {},
    deleteMany: () => {},
    deleteOne: () => {},
    find: () => {},
    findOne: () => {},
    updateOne: () => {}
  },
  fields: [
    {
      name: 'someField',
      type: 'text',
    },
  ],
}

export default Collection;

Type of change

  • [x] New feature (non-breaking change which adds functionality)
  • [ ] This change requires a documentation update

Checklist:

  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] Existing test suite passes locally with my changes
  • [ ] I have made corresponding changes to the documentation

kendelljoseph avatar Aug 14 '24 17:08 kendelljoseph