Skip to content

Commit

Permalink
fix(database): mongoose parseStringToQuery EJSON -> JSON (#926)
Browse files Browse the repository at this point in the history
* fix: parseStringToQuery EJSON -> JSON

* fix: ejson -> json parse in mongoose view pipeline queries
  • Loading branch information
ChrisPdgn authored Jan 29, 2024
1 parent a1dd80f commit 38d7ab0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import ConduitGrpcSdk, {
} from '@conduitplatform/grpc-sdk';
import { cloneDeep, isNil } from 'lodash';
import { parseQuery } from './parser';
import { EJSON } from 'bson';

export class MongooseSchema extends SchemaAdapter<Model<any>> {
model: Model<any>;
Expand Down Expand Up @@ -58,7 +57,7 @@ export class MongooseSchema extends SchemaAdapter<Model<any>> {
parseStringToQuery(
query: Query | SingleDocQuery | MultiDocQuery,
): ParsedQuery | ParsedQuery[] {
return typeof query === 'string' ? EJSON.parse(query) : query;
return typeof query === 'string' ? JSON.parse(query) : query;
}

async create(
Expand Down
3 changes: 1 addition & 2 deletions modules/database/src/adapters/mongoose-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
introspectedSchemaCmsOptionsDefaults,
} from '../../interfaces';
import { isNil } from 'lodash';
import { EJSON } from 'bson';

const parseSchema = require('mongodb-schema');

Expand Down Expand Up @@ -96,7 +95,7 @@ export class MongooseAdapter extends DatabaseAdapter<MongooseSchema> {
this.views[viewName] = viewModel;
await viewModel.model.createCollection({
viewOn: model.originalSchema.collectionName,
pipeline: EJSON.parse(query.mongoQuery),
pipeline: JSON.parse(query.mongoQuery),
});
} catch (e: any) {
if (!e.message.includes('Cannot overwrite')) {
Expand Down

0 comments on commit 38d7ab0

Please sign in to comment.