-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
WIP: Locked Pre defined Schemas / auto migration #6379
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
Conversation
Awesome! Could you please add an example on how to use it? |
Here an example of what i want to achieve: Assuming a export const Address = {
className: 'Address',
fields: {
objectId: { type: 'String' },
createdAt: {
type: 'Date',
},
updatedAt: {
type: 'Date',
},
ACL: { type: 'ACL' },
name: { type: 'String', required: true },
line1: { type: 'String', required: true },
line2: { type: 'String' },
city: { type: 'String', required: true },
zip: { type: 'String', required: true },
country: { type: 'String', required: true },
firstname: { type: 'String', required: true },
lastname: { type: 'String', required: true },
companyName: { type: 'String' },
isDefault: { type: 'Boolean' },
additionalInformations: { type: 'String' },
user: { type: 'Pointer', targetClass: '_User', required: true },
},
indexes: {
objectId: { objectId: 1 },
address: { country: 1, line1: 1 },
},
classLevelPermissions: {
find: { requiresAuthentication: true },
get: { requiresAuthentication: true },
update: { requiresAuthentication: true },
create: { requiresAuthentication: true },
delete: { requiresAuthentication: true },
readUserFields: ['user'],
writeUserFields: ['user'],
addField: {},
},
} And here a import { Address } from './Address';
const server = ParseServer.start({
databaseURI: process.env.MONGO_URL,
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY,
serverURL,
schemas: [Address],
port: Number(process.env.PORT),
}) |
I like where this is going. I did something like this for a project.
|
const cloudSchemas = await this.getAllClasses({ clearCache: true }); | ||
// We do not check classes to delete, developer need to delete manually classes | ||
// to avoid data loss during auto migration | ||
await Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should return this and lose the async.
i.e. return Promise.all(...
if (req.config.schemas) { | ||
throw new Parse.Error( | ||
Parse.Error.OPERATION_FORBIDDEN, | ||
'This server use schemas option, schemas creation/modification operations are blocked. You can still delete a class.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This server uses 'Schema Option'. Schema creation/modification operations are blocked. Classes can still be deleted. See: XYZ doc.
|
||
Object.keys(cloudSchema.fields) | ||
.filter(fieldName => isNotDefaultField(fieldName)) | ||
.map(async fieldName => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming accidental use of map
and async
> .forEach()
|
||
Object.keys(cloudSchema.indexes) | ||
.filter(indexName => isNotDefaultIndex(indexName)) | ||
.map(async indexName => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous comment on async
For Developers that wants this feature asap, here a script that i use on many project to achieve this feature: https://gist.github.com/Moumouls/e4f0c6470398efc7a6a74567982185fa |
I'm closing this one since i need a fresh re start with the gist script linked above 😄 New issue: #7063 |
With the recent add of GraphQL, schema less behavior of Parse could be a problem to use the GraphQL API correctly (due to the auto generation based on existing schemas). So from my own experience with a script that i use on my parse servers, i suggest to add an option
schemas
to Parse Server that allow to:Note: Missing tests, it's just a first architectural push
Tell me what you think about this ?