-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to create unique indexes #7289
Comments
Thanks for suggesting. From your description I assume this would be an enhancement, building on top of #7091. In that case you may want to wait until #7091 is finalized and merged and then look into how to go about a PR, or - if possible - coordinate with @Moumouls while #7091 is still in the works. |
In my parse-hipaa repo, I’m currently able to add indexes to a parse-server by doing the following in my index.js (this works for Postgres and Mongo as it leverages the methods the Parse Storage adapters already have to create indexes): async function createIndexes(){
await Parse.Cloud.run('ensureClassDefaultFieldsForParseCareKit');
let adapter = api.config.databaseController.adapter;
const indexEntityIdPostfix = '_entityId';
const indexEffectiveDatePostfix = '_effectiveDate';
const schema = {
fields: {
uuid: { type: 'String' }
},
};
const versionedSchema = {
fields: {
uuid: { type: 'String' },
entityId: { type: 'String' },
effectiveDate: { type: 'Date' }
},
};
await adapter.ensureUniqueness('Patient', versionedSchema, ['uuid'])
.catch(error => console.log(error));
await adapter.ensureIndex('Patient', versionedSchema, ['entityId'], 'Patient'+indexEntityIdPostfix, false)
.catch(error => console.log(error));
await adapter.ensureIndex('Patient', versionedSchema, ['effectiveDate'], 'Patient'+indexEffectiveDatePostfix, false)
.catch(error => console.log(error));
... Are you suggesting you need a different way? |
Good to know. Having to get the Adapter directly as a nuisance, but if you are all Ok with this, I won't change the existing Adapter code to add the |
@sadortun can you share the changes you propose making to the MongoDB adapter to allow for unique indexes? I would prefer using this method rather than calling |
Added a bounty due to high demand for this feature. |
I think we have a data structure challenge here. When you retrieve indexes ( also needed by Parse.Schema) you need to retrieve the uniqueness kind of the index. Current data structure is
By using an array it's easy to keep current interface of In that case, the only needed PR is:
|
Thanks for your feedback @mtrezza, yes it's important to keep consistency of usages , and also to keep a global view for each feature / fix, to avoid simple local fixes that will not work globally across SDK/apis |
New Feature / Enhancement Checklist
Current Limitation
parse-server
is currently lacking a way to update DB schema. #7091 should address most of this issue, but unfortunatly, it does not seems like there is a way to adduniqueIndex
despite being able to do so with themongo client
andpostgre
Feature / Enhancement Description
Add a
isUniqueIndex
parameterOr even better, add an
options
parameter. The downside of this would be that itwould probably cause problems in inter-compatibility between mongo and postgreExample Use Case
Alternatives / Workarounds
We need to bypass the Parse Schema logic and implement it with manual migrations ... its a real pain !
3rd Party References
The text was updated successfully, but these errors were encountered: