DynFork::QCommons::Indexes
Indexing collections.
Instance methods
This is a convenience method for creating a single index.
See: #create_indexes.
NOTE: For more details, please check the cryomongo documentation.
Example:
# Create one index without options…
ModelName.create_index(
keys: {
"a": 1,
"b": -1,
}
)
# or with options (snake_cased)
ModelName.create_index(
keys: {
"a": 1,
"b": -1,
},
options: {
unique: true,
}
)
# and optionally specify the name.
ModelName.create_index(
keys: {
"a": 1,
"b": -1,
},
options: {
name: "index_name",
}
)
Creates multiple indexes in the collection. NOTE: For more details, please check the official documentation. NOTE: For more details, please check the cryomongo documentation.
Example:
# Follow the same rules to create multiple indexes with a single method call.
ModelName.create_indexes([
{
keys: {a: 1},
},
{
keys: {b: 1}, options: {expire_after_seconds: 3600},
},
])
Drops a single index from the collection by the index name.
See: #drop_indexes.
NOTE: For more details, please check the cryomongo documentation.
Drops all indexes in the collection. NOTE: For more details, please check the official documentation. NOTE: For more details, please check the cryomongo documentation.
Gets index information for all indexes in the collection. NOTE: For more details, please check the official documentation. NOTE: For more details, please check the cryomongo documentation.