Skip to content

Commit

Permalink
fix(database): admin create schema return type regression (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
kon14 committed Aug 25, 2022
1 parent 6322b5d commit 4f7979c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
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

0 comments on commit 4f7979c

Please sign in to comment.