Skip to content
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

Why not use object to store schema type #5195

Closed
xVanTuring opened this issue Nov 27, 2018 · 3 comments
Closed

Why not use object to store schema type #5195

xVanTuring opened this issue Nov 27, 2018 · 3 comments

Comments

@xVanTuring
Copy link

xVanTuring commented Nov 27, 2018

Describe the solution you'd like
Currently parse server uses a string to set the schema type in mongo _SCHEMA, making it difficult to make additional settings such as required
If we use an Object, it will be easy to add an isRequired option.
And I tried this and modified a few functions, the parse server can create objects, and schema,The rest is still unclear.

Bottom it's the schema of the GameObject
tim 20181127143526

Function I edited

// MongoSchemaCollection.js
function mongoFieldToParseSchemaField(type) {
   return type;
}
function parseFieldTypeToMongoFieldType(fieldType) {
 return fieldType;
}
// MongoStorageAdapter.js
const mongoSchemaFromFieldsAndClassNameAndCLP=(/**/)=>{
  const mongoObject = {
    _id: className,
    objectId: {type:'String'}, //objectId: 'string',
    updatedAt: {type:'String'},
    createdAt: {type:'String'},
    _metadata: undefined,
  };
}

Hope this is useful

@georgesjamous
Copy link
Contributor

Why not use beforeSave in cloud code ?

@xVanTuring
Copy link
Author

Well,that will definitely work, I just think parse server complicates some issues.

@flovilmart
Copy link
Contributor

This is exactly the point of the beforeSave function, to let your define validation and custom logic. If this make is too complicated, you can always fork the project, and submit a PR when you have your feature ready!

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

No branches or pull requests

3 participants