Below is my code of Function on MongoDB it is not working & throwing Error as createIndex() is not a function.
exports = function(arg){
const db = context.services.get(“mongodb-atlas”).db(“myapp”).collection(‘event’);
ran on Mon Jun 28 2021 13:28:42 GMT+0530 (India Standard Time)
took 262.782947ms
error:
TypeError: ‘createIndex’ is not a function
trace:
TypeError: ‘createIndex’ is not a function
at exports (function.js:20:26(34))
at function_wrapper.js:3:1(21)
at :11:8(4)
at :2:15(7)
ran on Mon Jun 28 2021 13:34:27 GMT+0530 (India Standard Time)
took 278.613746ms
error:
TypeError: ‘createIndex’ is not a function
trace:
TypeError: ‘createIndex’ is not a function
at exports (function.js:20:26(38))
at function_wrapper.js:3:1(21)
at :11:8(4)
at :2:15(7)
logs:
{}
I’m not familiar with MongoDB Realm so I don’t know if it’s even possible to create an index that way.
You can try creating the index using the mongodb shell (or in atlas).
Goodluck,
Rafael,