-
Notifications
You must be signed in to change notification settings - Fork 1
MongoDB platform specific notes
LHCGreg edited this page Jan 20, 2014
·
4 revisions
- mongo scripts are .js javascript files that dbsc uses the
mongo
command line application to run.mongo
must be on your PATH.
A script might look like this:
db.createCollection('books');
db.books.ensureIndex({ name: 1 });
db.books.insert(
[
{
name: 'Charlie and the Chocolate Factory',
author: 'Roald Dahl'
}
]
);
- Imports are done via
mongodump
/mongorestore
for each collection.mongodump
andmongorestore
must be on your PATH to import data from another database. - Because a collection must be destroyed before importing with
mongorestore
, you will lose indexes on imported collections and get whatever indexes the source database has on the collection. This differs from every other dbsc flavor. - MongoDB does not have a command to create a database. When mongodbsc creates a database, here's what happens:
- mongodbsc ensures that the database does not already exist.
- If using authentication, add the authenticating user as an admin user to the new database.
- A temporary collection is created and dropped in the database to force the database to be created.
- If a
-dbCreateTemplate
was specified, the template will be run on the newly created database.$DatabaseName$ will be replaced with the database name.