Skip to content

Create unique index#164

Open
gladkia wants to merge 5 commits intojeroen:masterfrom
gladkia:create_unique_index
Open

Create unique index#164
gladkia wants to merge 5 commits intojeroen:masterfrom
gladkia:create_unique_index

Conversation

@gladkia
Copy link

@gladkia gladkia commented Nov 27, 2018

Hi,
I've just added the support for creating indices with "unique" property (.c/.R code + R unit tests).

In theory, the 'addOpts' parameter (the list) can be extended with other properties of the created index.

@codecov-io
Copy link

codecov-io commented Nov 27, 2018

Codecov Report

Merging #164 into master will decrease coverage by 0.13%.
The diff coverage is 3.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
- Coverage   37.65%   37.52%   -0.14%     
==========================================
  Files         130      130              
  Lines       21910    21929      +19     
==========================================
- Hits         8250     8228      -22     
- Misses      13660    13701      +41
Impacted Files Coverage Δ
src/collection.c 35.84% <0%> (-2.82%) ⬇️
R/client.R 32.14% <0%> (-4.6%) ⬇️
R/mongo.R 49.7% <50%> (ø) ⬆️
src/mongoc/mongoc-topology-description.c 54.73% <0%> (-2.52%) ⬇️
src/mongoc/mongoc-server-description.c 53.36% <0%> (-1.08%) ⬇️
src/gridfs.c 66.16% <0%> (-0.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db768cb...c3df7ab. Read the comment docs.

@jeroen
Copy link
Owner

jeroen commented Nov 28, 2018

Thanks, will review this when I'm back from vacation.

@jeroen
Copy link
Owner

jeroen commented Dec 1, 2018

It would be nice if we can make this work for any option by passing down the options as a json object (as we do for the keys parameter).

@gladkia
Copy link
Author

gladkia commented Dec 4, 2018

Hi @jeroen,

  1. I looked into the mongoDB options available for create_indexes() command.

We can split options into two categories:

  • documents

    • keys ( already supported)
    • partialFilterExpression
    • storageEngine
    • weights
    • collation
  • single-value elements (integer/boolean/string)

    • name: string
    • background: boolean
    • unique: boolean (already supported)
    • sparse: boolean
    • expireAfterSeconds: integer
    • default_language: string
    • language_override: string
    • textIndexVersion: integer
    • 2dsphereIndexVersion: integer
    • bits: integer
    • min: number
    • max: number
    • bucketSize: number
  1. Do you mean changing 'addOpts' parameter from the list() to the JSON object? Sure, I can refactor code that way. This will be easy (asserts in R function) for the first category of options (single value elements) and will require more sophisticated actions (especially tests) for the second category (documents). We should probably define single argument per each option in the C function "R_mongo_collection_create_index" (to minimize the work on the C level as much as possible). Is that OK ?

  2. I think that we can start with single-value elements. This part of work is the easy to implement and test. Then we can consider adding document options. What do you think about it ?

@ghost
Copy link

ghost commented Jan 12, 2021

Hi, is there any update on this? I can't see the addOpts parameter in run() yet.

@jeroen jeroen force-pushed the master branch 2 times, most recently from 032d2f1 to 8bdd0e3 Compare March 17, 2025 19:49
@jeroen jeroen force-pushed the master branch 3 times, most recently from 12d33b7 to 02d0e8d Compare April 1, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants