Indexes are recorded in the following format:
INDEXES = {
- 'identifier': { # key identifier used for possibly deprecating later
- 'collection': 'thiscollection',
- 'index': [index_foo_goes_here]}}
+ 'collection_name': {
+ 'identifier': { # key identifier used for possibly deprecating later
+ 'index': [index_foo_goes_here]}}
... and anything else being parameters to the create_index function
(including unique=True, etc)
REQUIRED READING:
- http://kylebanker.com/blog/2010/09/21/the-joy-of-mongodb-indexes/
+
- http://www.mongodb.org/display/DOCS/Indexes
- http://www.mongodb.org/display/DOCS/Indexing+Advice+and+FAQ
"""
# Matching an object to an uploader + slug.
# MediaEntries are unique on these two combined, eg:
# /u/${myuser}/m/${myslugname}/
- 'collection': 'media_entries',
'index': [('uploader', ASCENDING),
('slug', ASCENDING)],
'unique': True},
'mediaentry_created': {
# A global index for all media entries created, in descending
# order. This is used for the site's frontpage.
- 'collection': 'media_entries',
'index': [('created', DESCENDING)]},
'mediaentry_uploader_created': {
# Indexing on uploaders and when media entries are created.
# Used for showing a user gallery, etc.
- 'collection': 'media_entries',
'index': [('uploader', ASCENDING),
('created', DESCENDING)]}}
-ACTIVE_INDEXES.update(
- [MEDIAENTRY_INDEXES])
+ACTIVE_INDEXES['media_entries'] = MEDIAENTRY_INDEXES
# User indexes
'user_username_unique': {
# Index usernames, and make sure they're unique.
# ... I guess we might need to adjust this once we're federated :)
- 'collection': 'users',
- 'index': 'username'},
+ 'index': 'username',
+ 'unique': True},
'user_created': {
# All most recently created users
- 'collection': 'users',
'index': 'created'}}
-ACTIVE_INDEXES.update(
- [USER_INDEXES])
+ACTIVE_INDEXES['users'] = USER_INDEXES
####################
# Deprecated indexes
####################
-DEPRECATED_INDEXES = []
+DEPRECATED_INDEXES = {}