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

fix(database): admin create schema return type regression #289

Merged
merged 3 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/database/src/admin/documents.admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class DocumentsAdmin {
if (isNil(schema)) {
throw new GrpcError(status.NOT_FOUND, 'Schema does not exist');
}
await await this.database.getSchemaModel(schemaName).model.deleteOne({ _id: id });
await this.database.getSchemaModel(schemaName).model.deleteOne({ _id: id });
return 'Ok';
}
}
7 changes: 4 additions & 3 deletions modules/database/src/admin/schema.admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export class SchemaAdmin {
};
}

const schemasPromise = await this.database
const schemasPromise = this.database
.getSchemaModel('_DeclaredSchema')
.model.findMany(query, skip, limit, undefined, sort);
const documentsCountPromise = await this.database
const documentsCountPromise = this.database
.getSchemaModel('_DeclaredSchema')
.model.countDocuments(query);

Expand Down Expand Up @@ -160,9 +160,10 @@ export class SchemaAdmin {
: { ...modelOptions, conduit: { cms: { enabled, crudOperations } } };
schemaOptions.conduit.permissions = permissions; // database sets missing perms to defaults

return this.schemaController.createSchema(
await this.schemaController.createSchema(
new ConduitSchema(name, fields, schemaOptions),
);
return await this.database.getSchemaModel('_DeclaredSchema').model.findOne({ name });
}

async patchSchema(call: ParsedRouterRequest): Promise<UnparsedRouterResponse> {
Expand Down
2 changes: 1 addition & 1 deletion modules/database/src/permissions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Schema, SchemaAdapter } from '../interfaces';
import { Schema } from '../interfaces';

export async function canCreate(moduleName: string, schema: Schema) {
if (moduleName === 'database' && schema.originalSchema.name === '_DeclaredSchema')
Expand Down