Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unable to create Mongoose compound indexes when running under Railway #203

Closed
kevindente opened this Issue · 2 comments

2 participants

@kevindente

This issue is complicated, and I don't pretend to understand all the subtleties of what's going on here. In my app I'm using a customSchema to access the database with Mongoose directly. It's been working fine, until I tried adding compound indexes for a schema, and it started failing in really mysterious way (basically as if the object literal that was passed in as the index specifier was an empty object but it isn't).

After several hours of tracing through code, I think what's happening is that Railway is running the schema.js file in a new Node context, and the object literal defining the index fields is added to Mongoose at that point. However, later when the Mongoose call to the native driver's ensureIndex actually fires, it's happening in a different context, and the object literal index specifier no longer works (specifically, the driver checks that the literal's constructor property equals Object, but the check fails). I believe it's the same issue described:
joyent/node#1518

I'm not sure what the solution is here.

@anatoliychakkaev
Collaborator
@kevindente

Thanks. I'll report it to the Mongoose project too, see if they want to do anything on their side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.