-
Notifications
You must be signed in to change notification settings - Fork 4.1k
How to add a MongoDB Index
Phoenix Eliot edited this page May 4, 2017
·
1 revision
You want to add a new index to MongoDB, so that you can query over that field quickly.
Add the index to the server Schema, and then get a CoCo Engineer to add the index to the production MongoDB manually. (Manually adding it ahead of time is preferable to doing it during deploy)
In server/models/(your model).schema
, add the index. (Note: Mongoose makes indexes background: true
by default here)
Eg: PrepaidSchema.index({'joiners.userID': 1}, {sparse: true})
Then, before deploying this code, ask a CodeCombat engineer to add the index. Make sure to add background: true
to the options here.
db.prepaids.createIndex({'joiners.userID': 1}, {sparse: true, background: true})
CodeCombat | Home | Blog | Forum | Teachers | Legal | Contribute
- Home
- Archmage Home
- Artisan Home
- Diplomat Home
- Archmage General
- Mission statement
- Coco Models
- Coding Guidelines
- Cookbook
- File system
- JSON Schema
- Technical overview
- Testing
- Third party software and services
- Artisan General
- Building A Level
- Coding Guidelines for Artisans
- Editing Thang Components
- Important Artisan Concepts
- Keyboard Shortcuts
- Debugging
- Artisan How-To Index
- Diplomat General
- i18n
- i18n Glossary nb
- i18n Glossary ru
- i18n Glossary es-419
- Dev Setup
- Dev Setup: Linux
- Dev Setup: Windows
- Dev Setup: Mac
- Dev Setup: Vagrant
- Dev Setup: Issues
- Game Engine
- Component
- Multiplayer
- Surface
- System
- Thang
- Thang Component System
- Tome
- World
- Artisan Tabs
- Components And Systems
- Scripts
- Settings
- Thangs
- Other
- Aether
- Client models
- Developer organization
- Educational Standards
- Events, subscriptions, shortcuts
- Chat Room
- Chat Room Rules
- Permissions
- Project Ideas List
- Treema
- Versioning
- Views