question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't deleteMany when using UUID

See original GitHub issue

I get the following error message when trying to deleteMany a model that has uuid.

I’m currently using postgres as database provider

model

model Vault {
  id String @id @default(uuid())
  createdAtTick Int
  x Int
  y Int
  userId String?
  resourceId String
  facilityId String
}

code

const { findMany, deleteMany } = photon.vaults];
const results = await findMany();

if (results.length > 0) {
  await deleteMany({
    where: { id: { in: results.map(({ id }) => id) } },
  });
}

error message

    Invalid `photon.vaults.deleteMany()` invocation:

    {
      where: {
        id: {
          in: [
            'd4082b42-b161-11e9-8754-6542abf52968',
            'd4082b45-b161-11e9-8754-6542abf52968',
            'd4f9de42-b161-11e9-b0ed-f5aa37e6d1ec',
            'd4f9de45-b161-11e9-b0ed-f5aa37e6d1ec'
          ]
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        }
      }
    }

    Argument in: Got invalid value
    [
      'd4082b42-b161-11e9-8754-6542abf52968',
      'd4082b45-b161-11e9-8754-6542abf52968',
      'd4f9de42-b161-11e9-b0ed-f5aa37e6d1ec',
      'd4f9de45-b161-11e9-b0ed-f5aa37e6d1ec'
    ]
    on photon.deleteManyVault. Provided List<UUID>, expected List<String>.

      1836 |         return `${this.args
      1837 |             .map(arg => arg.toString())
    > 1838 |             .filter(a => a)
           |                       ^
      1839 |             .join('\n')}`;
      1840 |     }
      1841 |     collectErrors() {

      at Document.validate (src/server/photon/runtime/index.js:1838:23)
      at VaultClient.validate (src/server/photon/index.js:250:22)
      at VaultClient.document [as then] (src/server/photon/index.js:272:61)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
timsuchanekcommented, Jul 30, 2019

Thanks for reporting! Fixed in latest alpha.

0reactions
dortamiguelcommented, Aug 5, 2019

Looks like the problem is caused by another reason, but maybe fixing one will fix this one?

Read more comments on GitHub >

github_iconTop Results From Across the Web

db.collection.deleteMany() — MongoDB Manual
Specifies deletion criteria using query operators. To delete all documents in a collection, pass in an empty document ( { } ).
Read more >
How to delete N numbers of documents in mongodb
FYI: you cannot remove documents from a capped collection. ... Use the same filter (owner:uid) to match the first find, and delete many...
Read more >
Unable to delete doc with UUID as _id · Issue #668 - GitHub
Document not found appears when I try to delete a doc that uses UUID instead of ObjectId. I use UUIDs because it looks...
Read more >
How to find orphan documents and delete them?
Step 2:-- deleteMany() will delete those child document whose parents are no longer exists in the parent collections. db.child.deleteMany({"_id" ...
Read more >
Mass delete via HTTP/Rest how do you do it? - ITNEXT
In the project I am working on, we have a need to sometimes delete several items at once. The UI would send a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found