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

MongoDB Search Strategy #1204

Closed
Sean12697 opened this issue Nov 1, 2021 · 10 comments
Closed

MongoDB Search Strategy #1204

Sean12697 opened this issue Nov 1, 2021 · 10 comments

Comments

@Sean12697
Copy link

Is your feature request related to a problem? Please describe.

Due to the DefaultSeachPlugin within @vendure/core not having an implemented MongoDB Search Strategy, even if I configure VendureConfig correctly using the TypeORM MongoDB Connection settings (as mentioned in #132 (comment) from 2019), I still receive the following error.

sean@pop-os:~/temp/e2e-vendure/project-name$ npm run start

> [email protected] start
> concurrently yarn:run:*

yarn run v1.22.17
yarn run v1.22.17
$ ts-node ./src/index-worker.ts
$ ts-node ./src/index.ts
[run:worker] info 01/11/21, 16:43 - [Vendure Worker] Bootstrapping Vendure Worker (pid: 6183)... 
[run:server] info 01/11/21, 16:43 - [Vendure Server] Bootstrapping Vendure Server (pid: 6191)... 
[run:worker] error 01/11/21, 16:43 - [ExceptionHandler] error.database-not-supported-by-default-search-plugin
[run:worker] Error: error.database-not-supported-by-default-search-plugin
[run:worker]     at FulltextSearchService.setSearchStrategy (/home/sean/temp/e2e-vendure/project-name/node_modules/@vendure/core/src/plugin/default-search-plugin/fulltext-search.service.ts:125:23)
[run:worker]     at new FulltextSearchService (/home/sean/temp/e2e-vendure/project-name/node_modules/@vendure/core/src/plugin/default-search-plugin/fulltext-search.service.ts:44:14)
[run:worker]     at Injector.instantiateClass (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:286:19)
[run:worker]     at callback (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:42:41)
[run:worker]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[run:worker]     at async Injector.resolveConstructorParams (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:114:24)
[run:worker]     at async Injector.loadInstance (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:46:9)
[run:worker]     at async Injector.loadProvider (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:68:9)
[run:worker]     at async Promise.all (index 3)
[run:worker]     at async InstanceLoader.createInstancesOfProviders (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/instance-loader.js:43:9) 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[run:worker] yarn run run:worker exited with code 1
[run:server] error 01/11/21, 16:43 - [ExceptionHandler] error.database-not-supported-by-default-search-plugin
[run:server] Error: error.database-not-supported-by-default-search-plugin
[run:server]     at FulltextSearchService.setSearchStrategy (/home/sean/temp/e2e-vendure/project-name/node_modules/@vendure/core/src/plugin/default-search-plugin/fulltext-search.service.ts:125:23)
[run:server]     at new FulltextSearchService (/home/sean/temp/e2e-vendure/project-name/node_modules/@vendure/core/src/plugin/default-search-plugin/fulltext-search.service.ts:44:14)
[run:server]     at Injector.instantiateClass (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:286:19)
[run:server]     at callback (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:42:41)
[run:server]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[run:server]     at async Injector.resolveConstructorParams (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:114:24)
[run:server]     at async Injector.loadInstance (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:46:9)
[run:server]     at async Injector.loadProvider (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/injector.js:68:9)
[run:server]     at async Promise.all (index 3)
[run:server]     at async InstanceLoader.createInstancesOfProviders (/home/sean/temp/e2e-vendure/project-name/node_modules/@nestjs/core/injector/instance-loader.js:43:9) 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[run:server] yarn run run:server exited with code 1
sean@pop-os:~/temp/e2e-vendure/project-name$ 

Looking at #505 I could modify the following line so I no longer get the error.database-not-supported-by-default-search-plugin error, although that doesn't add the functionality magically.

private setSearchStrategy() {
switch (this.connection.rawConnection.options.type) {
case 'mysql':
case 'mariadb':
this.searchStrategy = new MysqlSearchStrategy(this.connection, this.options);
break;
case 'sqlite':
case 'sqljs':
case 'better-sqlite3':
this.searchStrategy = new SqliteSearchStrategy(this.connection, this.options);
break;
case 'postgres':
this.searchStrategy = new PostgresSearchStrategy(this.connection, this.options);
break;
default:
throw new InternalServerError(`error.database-not-supported-by-default-search-plugin`);
}
}
}

Describe the solution you'd like
A MongoDB Search Strategy be implemented within @vendure/core's DefaultSeachPlugin.

Describe alternatives you've considered
Being pointed to an already existing implementation of this, or a neat work around. Failing all of the above, I can just hackily change the switch case.

Additional context
N/A

@michaelbromley
Copy link
Member

Hi Sean,

Do the other parts of Vendure seem to work with Mongo? In the TypeORM docs it states that TypeORM has basic MongoDB support, and I've never given any thought to testing in Mongo, so I would be quite surprised if search is the only thing that does not work properly!

I do not plan to support Mongo, so I won't be adding official support to the default search plugin, sorry.

I'm interested to learn more about why you would like to use Mongo to power Vendure though. Could you tell me a bit about your use-case?

@Sean12697
Copy link
Author

Sean12697 commented Nov 2, 2021

Good Morning @michaelbromley,

I'll test out the functionality this week by hacking the switch case or changing the DefaultSeachPlugin requirement part of the code generated by the boilerplate, I'm uncertain what other underlying TypeORM functions you've had to config for Vendure, so I don't know if this is the only change required. Although, if it does work fully with only that one issue, I might implement a MongoDB Search Strategy myself, or at least make an attempt and reference this issue.

Use case wise I'm uncertain how much I can say, although the general points are the flexibility of MongoDB without having a strict schema, being able to loosely type with Typescript, then horizontal scaling.

@michaelbromley
Copy link
Member

Ok! A quicker way to check whether the other functionality works with Mongo would be to just omit the DefaultSearchPlugin from your config plugins array.

@Sean12697
Copy link
Author

Yeah, I need to poke into it between meeting, but I received the following logs when removing the DefaultSearchPlugin from my config plugins array, I think this is because the database is not populated.

sean@pop-os:~/temp/e2e-vendure/sean@pop-os:~/temp/e2e-vendure/project-name$ npm run start

> [email protected] start
> concurrently yarn:run:*

yarn run v1.22.17
yarn run v1.22.17
$ ts-node ./src/index.ts
$ ts-node ./src/index-worker.ts
[run:server] info 02/11/21, 12:41 - [Vendure Server] Bootstrapping Vendure Server (pid: 7170)... 
[run:worker] info 02/11/21, 12:41 - [Vendure Worker] Bootstrapping Vendure Worker (pid: 7181)... 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 0) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 1) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 2) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 3) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 4) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 5) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 6) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 7) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 8) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 9) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 10) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 11) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 12) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 13) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 14) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 15) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 16) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 17) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 18) 
[run:worker] error 02/11/21, 12:41 - [Vendure Worker] Timed out when awaiting the DB schema to be ready!
[run:worker] TypeError: Cannot read property 'prototype' of undefined
[run:worker]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:worker]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:worker]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:worker]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:worker]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62) 
[run:worker] TypeError: Cannot read property 'prototype' of undefined
[run:worker]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:worker]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:worker]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:worker]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:worker]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
[run:server] info 02/11/21, 12:41 - [AssetServerPlugin] Creating asset server middleware 
[run:server] info 02/11/21, 12:41 - [EmailPlugin] Creating dev mailbox middleware 
[run:server] info 02/11/21, 12:41 - [AdminUiPlugin] Creating admin ui middleware (prod mode) 
[run:server] info 02/11/21, 12:41 - [RoutesResolver] HealthController {/health}: 
[run:server] info 02/11/21, 12:41 - [RouterExplorer] Mapped {/health, GET} route 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 0) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 1) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 2) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 3) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 4) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 5) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 6) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 7) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 8) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 9) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 10) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 11) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 12) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 13) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 14) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 15) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 16) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 17) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 18) 
[run:server] error 02/11/21, 12:42 - [Vendure Server] Timed out when awaiting the DB schema to be ready!
[run:server] TypeError: Cannot read property 'prototype' of undefined
[run:server]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:server]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:server]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:server]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:server]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62) 
[run:server] TypeError: Cannot read property 'prototype' of undefined
[run:server]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:server]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:server]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:server]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:server]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
$ npm run start

> [email protected] start
> concurrently yarn:run:*

yarn run v1.22.17
yarn run v1.22.17
$ ts-node ./src/index.ts
$ ts-node ./src/index-worker.ts
[run:server] info 02/11/21, 12:41 - [Vendure Server] Bootstrapping Vendure Server (pid: 7170)... 
[run:worker] info 02/11/21, 12:41 - [Vendure Worker] Bootstrapping Vendure Worker (pid: 7181)... 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 0) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 1) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 2) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 3) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 4) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 5) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 6) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 7) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 8) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 9) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 10) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 11) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 12) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 13) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 14) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 15) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 16) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 17) 
[run:worker] warn 02/11/21, 12:41 - [Vendure Worker] Awaiting DB schema creation... (attempt 18) 
[run:worker] error 02/11/21, 12:41 - [Vendure Worker] Timed out when awaiting the DB schema to be ready!
[run:worker] TypeError: Cannot read property 'prototype' of undefined
[run:worker]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:worker]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:worker]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:worker]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:worker]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62) 
[run:worker] TypeError: Cannot read property 'prototype' of undefined
[run:worker]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:worker]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:worker]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:worker]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:worker]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
[run:server] info 02/11/21, 12:41 - [AssetServerPlugin] Creating asset server middleware 
[run:server] info 02/11/21, 12:41 - [EmailPlugin] Creating dev mailbox middleware 
[run:server] info 02/11/21, 12:41 - [AdminUiPlugin] Creating admin ui middleware (prod mode) 
[run:server] info 02/11/21, 12:41 - [RoutesResolver] HealthController {/health}: 
[run:server] info 02/11/21, 12:41 - [RouterExplorer] Mapped {/health, GET} route 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 0) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 1) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 2) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 3) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 4) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 5) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 6) 
[run:server] warn 02/11/21, 12:41 - [Vendure Server] Awaiting DB schema creation... (attempt 7) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 8) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 9) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 10) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 11) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 12) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 13) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 14) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 15) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 16) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 17) 
[run:server] warn 02/11/21, 12:42 - [Vendure Server] Awaiting DB schema creation... (attempt 18) 
[run:server] error 02/11/21, 12:42 - [Vendure Server] Timed out when awaiting the DB schema to be ready!
[run:server] TypeError: Cannot read property 'prototype' of undefined
[run:server]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:server]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:server]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:server]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:server]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62) 
[run:server] TypeError: Cannot read property 'prototype' of undefined
[run:server]     at FindCursor.cursor.toArray (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:686:37)
[run:server]     at MongoEntityManager.<anonymous> (/home/sean/temp/e2e-vendure/project-name/src/entity-manager/MongoEntityManager.ts:104:23)
[run:server]     at step (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
[run:server]     at Object.next (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
[run:server]     at fulfilled (/home/sean/temp/e2e-vendure/project-name/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)

@michaelbromley
Copy link
Member

Do you have dbConnectionOptions.synchronize: true? If not, try it with that.

@Sean12697
Copy link
Author

Do you have dbConnectionOptions.synchronize: true? If not, try it with that.

Ahhh, yes, I had to set that to false since that caused some issues, my current redacted dbConnectionOptions are the following, I know there's some redundancy due to parameters being overwritten.

{
    type: 'mongodb',
    synchronize: false,
    logging: false,
    database: 'xxx',
    url: 'mongodb+srv://xxxx:[email protected]/xxx?retryWrites=true&w=majority&useNewUrlParser=true&useUnifiedTopology=true',
    port: 27017, 
    username: 'xxxx',
    password: 'xxxxxxxxxxxxxxxxxx',
    migrations: [path.join(__dirname, '../migrations/*.ts')],
}

@Sean12697
Copy link
Author

This is what happens when I have dbConnectionOptions.synchronize: true, it looks like it simply cannot connect in the first place, where when it's dbConnectionOptions.synchronize: false it can connect, but has other issues.

sean@pop-os:~/temp/e2e-vendure/project-name$ npm run start

> [email protected] start
> concurrently yarn:run:*

yarn run v1.22.17
yarn run v1.22.17
$ ts-node ./src/index.ts
$ ts-node ./src/index-worker.ts
[run:server] info 03/11/21, 09:47 - [Vendure Server] Bootstrapping Vendure Server (pid: 10849)... 
[run:worker] info 03/11/21, 09:47 - [Vendure Worker] Bootstrapping Vendure Worker (pid: 10857)... 
[run:worker] error 03/11/21, 09:47 - [TypeOrmModule] Unable to connect to the database. Retrying (1)...
[run:worker] MongoServerError: Error in specification { name: "IDX_a23445b2c942d8dfcae15b8de2", key: {}, unique: false, sparse: null, background: null } :: caused by :: Index keys cannot be empty.
[run:worker]     at MessageStream.messageHandler (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/connection.ts:740:20)
[run:worker]     at MessageStream.emit (events.js:400:28)
[run:worker]     at MessageStream.emit (domain.js:475:12)
[run:worker]     at processIncomingData (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:167:12)
[run:worker]     at MessageStream._write (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:64:5)
[run:worker]     at writeOrBuffer (internal/streams/writable.js:358:12)
[run:worker]     at MessageStream.Writable.write (internal/streams/writable.js:303:10)
[run:worker]     at TLSSocket.ondata (internal/streams/readable.js:731:22)
[run:worker]     at TLSSocket.emit (events.js:400:28)
[run:worker]     at TLSSocket.emit (domain.js:475:12) 
[run:server] error 03/11/21, 09:47 - [TypeOrmModule] Unable to connect to the database. Retrying (1)...
[run:server] MongoServerError: Error in specification { name: "IDX_a23445b2c942d8dfcae15b8de2", key: {}, unique: false, sparse: null, background: null } :: caused by :: Index keys cannot be empty.
[run:server]     at MessageStream.messageHandler (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/connection.ts:740:20)
[run:server]     at MessageStream.emit (events.js:400:28)
[run:server]     at MessageStream.emit (domain.js:475:12)
[run:server]     at processIncomingData (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:167:12)
[run:server]     at MessageStream._write (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:64:5)
[run:server]     at writeOrBuffer (internal/streams/writable.js:358:12)
[run:server]     at MessageStream.Writable.write (internal/streams/writable.js:303:10)
[run:server]     at TLSSocket.ondata (internal/streams/readable.js:731:22)
[run:server]     at TLSSocket.emit (events.js:400:28)
[run:server]     at TLSSocket.emit (domain.js:475:12) 
[run:worker] error 03/11/21, 09:47 - [TypeOrmModule] Unable to connect to the database. Retrying (2)...
[run:worker] MongoServerError: Error in specification { name: "IDX_a23445b2c942d8dfcae15b8de2", key: {}, unique: false, sparse: null, background: null } :: caused by :: Index keys cannot be empty.
[run:worker]     at MessageStream.messageHandler (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/connection.ts:740:20)
[run:worker]     at MessageStream.emit (events.js:400:28)
[run:worker]     at MessageStream.emit (domain.js:475:12)
[run:worker]     at processIncomingData (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:167:12)
[run:worker]     at MessageStream._write (/home/sean/temp/e2e-vendure/project-name/node_modules/mongodb/src/cmap/message_stream.ts:64:5)
[run:worker]     at writeOrBuffer (internal/streams/writable.js:358:12)
[run:worker]     at MessageStream.Writable.write (internal/streams/writable.js:303:10)
[run:worker]     at TLSSocket.ondata (internal/streams/readable.js:731:22)
[run:worker]     at TLSSocket.emit (events.js:400:28)
[run:worker]     at TLSSocket.emit (domain.js:475:12)

@michaelbromley
Copy link
Member

Ok, that confirms my suspicion that there would be a lot more incompatible with Mongo than just the search strategy.

Basically if you want to use Vendure, you need to use one of the supported relational DBs. I'm pretty certain that relational DBs are a better fit for the types of data we are modelling in Vendure anyway.

@Sean12697
Copy link
Author

If you know what either TypeORM doesn't cover, or what you've had to write on top of / extend TypeORM for custom functions (like the Search Strategies, where you've written implementations for mariadb, better-sqlite3 and postgres), I would be interested in looking into what it would take to make MongoDB reach the minimum compatibility level to function.

@michaelbromley
Copy link
Member

Just had a look through the TypeORM issues and it seems like the MongoDB driver does not support:

which are absolute show-stoppers right there. Unless those features get proper support, there's basically no possibility that Vendure will work with Mongo.

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

2 participants