Comments (7)
Edit: Or to include URIs with absent name or modified host, possible fix. This doesn't fully support mongo URIs either. Options, for example, are ignored. This does support mongodb://host:port/name style URIs.
from cobalt.
@hobindar nice catch! you can actually use .slice(-1)
to get the last element of an array, so this might a bit cleaner:
process.env.COBALT_MONGO_URI.split('/').slice(-1)
Thanks for the contribution!
from cobalt.
Just saw the edit, I like this idea better. It looks like you can get the host/name/port through the Mongoose connection object, so you might be able to avoid having to parse the URI.
let database = mongoose.connection.name
let host = mongoose.connection.host
let port = mongoose.connection.port
- http://stackoverflow.com/questions/13759400/mongoose-js-get-mongo-db-name-url-from-model-instance#comment53622820_13759400
- http://stackoverflow.com/questions/23176174/mongoose-and-mongo-error-mongoose-connection-host-returns-null/23177488#23177488
from cobalt.
Were you thinking something more like this?
from cobalt.
Yeah, that's a lot cleaner. One more thing, mongoimport
actually has a --port
flag, so you don't even need to form that part yourself.
from cobalt.
Here it is with --port
flag.
from cobalt.
@hobindar Looks good to me. 👍
Submit the PR, @qasim will review when he can and merge changes.
from cobalt.
Related Issues (20)
- Transportation API HOT 4
- Athletics API HOT 4
- Date parameters in filter endpoints should support multiple formats? HOT 3
- Exams API HOT 4
- Events API HOT 1
- Building API: keys out of order HOT 5
- Time and Date updates HOT 2
- Revamp how we filter HOT 8
- Should we discontinue /search in favour of /filter? HOT 2
- Food API: Move filter to newer ParseQuery model + abstract the `open` filter
- Campus filter not working? HOT 1
- 404 for cdf/labs and printers HOT 6
- DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead HOT 1
- GET courses doesn't return any locations. HOT 2
- Problem in self-hosting HOT 6
- API server down? HOT 2
- 502 bad gateway HOT 2
- UTM courses not returning full course codes for its prerequisites
- API 502 responses HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobalt.