Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debitoor/mongoindex
Generare ensureIndex statements based on indexes read from a MongoDB database. Use it for copying indexes from one db to another. From production to development/staging for example
https://github.com/debitoor/mongoindex
Last synced: 12 days ago
JSON representation
Generare ensureIndex statements based on indexes read from a MongoDB database. Use it for copying indexes from one db to another. From production to development/staging for example
- Host: GitHub
- URL: https://github.com/debitoor/mongoindex
- Owner: debitoor
- License: mit
- Created: 2014-02-28T09:04:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-27T10:00:17.000Z (about 4 years ago)
- Last Synced: 2024-04-14T22:47:38.055Z (7 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 33
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mongoindex
===========Generare ensureIndex statements based on indexes read from a MongoDB database.
Use it for copying indexes from one db to another. From production to development/staging for example.
installation
------------```
$ npm install -g mongoindex
```usage
-----
```
$ mongoindex [mongo_connection_string] [ensure_index_output_file]
```examples
-------Generate ensureIndexes.js script from database called `development`on local machine
```
$ mongoindex development ensureIndexes.js
```Generate ensureIndexes.js script form remote database with auth
```
$ mongoindex mongodb://user:[email protected]:10022/mydatabase ensureIndexes.js
```See more about (mongo connectionstrings)[https://www.google.dk/search?q=mongodeb+connectionstring]
running the ensureIndexes.js file generated
-------------------------------------------
You need to actually run the ensureIndexes.js file generated programatically.You need to pass in a reference to an open Db object from mongodb (needs to have .ensureIndex method):
```js
var mongodb = require('mongodb');
(new mongodb.MongoClient()).connect('mongodb://127.0.0.1/mydb', function(err, db){
require('./ensureIndexes.js')(db);
};
```