Hi guys. In mongodb, it is possible to generate 2d...
# mongodb
r
Hi guys. In mongodb, it is possible to generate 2d and 2dsphere indexes. Do you know a way or a "hack" to force the @@index to be from 2d or 2dsphere type?
1
p
@Ruben i didn't test it so do it by yourself. i used similar approach for TTL indexes and it worked just fine
Copy code
await prisma.$runCommandRaw({
    createIndexes: 'MyCollection',
    indexes: [
      {
        key: {
          location: '2dsphere',
        },
        name: 'index_name'
      },
    ],
  });
you need to run it after running the migration
as for doing it on schema level - probably no way for now
r
Thank you for that. I created the index manually and I kept that same index name with @@index and it worked well. So I will use your code to automate it 👍