lane711 / sonicjs

SonicJs Headless CMS - Blazing Fast Headless CMS built on Cloudflare Workers. 100% Javascript Based
https://sonicjs.com
843 stars 115 forks source link

Add Full Mongo Support #94

Closed lane711 closed 1 year ago

lane711 commented 2 years ago

TypeORM doesn't provide full support OOTB so some additional effort will be required to getting SonicJs fully functioning with Mongo.

In the meantime, SQLite and Postgres have been fully tested and are running multiple production websites.

mandaputtra commented 2 years ago

Hello, could you provide what are full support OOTB? So I can fully test it. I'm still exploring the CMS right now.

lane711 commented 2 years ago

Hi, Actually we recently drastically simplified the data model so its possible that MongoDB works OOTB as of now. To test it simply use this in your .env file to run Mongo as your db:

# MonngoDB
 TYPEORM_CONNECTION=mongodb
 TYPEORM_URL=mongodb://localhost:27017/sonicjs
 TYPEORM_HOST=localhost
 TYPEORM_USERNAME=rootp
 TYPEORM_PASSWORD=admin
 TYPEORM_DATABASE=sonicjs
 TYPEORM_PORT=27017
 TYPEORM_SYNCHRONIZE=true
 TYPEORM_LOGGING=true

Please let me know if you run into any issues. Thanks for considering SonicJs for your project!

mandaputtra commented 2 years ago

Thanks, will update you after through test

mandaputtra commented 2 years ago

I stuck on this step after trying to connect to mongodb.

/Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/entity-manager/MongoEntityManager.js:122
                                    var propertyName = metadata.objectIdColumn.propertyName;
                                                                               ^

TypeError: Cannot read properties of undefined (reading 'propertyName')
    at /Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/entity-manager/MongoEntityManager.js:122:80
    at Array.map (<anonymous>)
    at MongoEntityManager.<anonymous> (/Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/entity-manager/MongoEntityManager.js:114:38)
    at step (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:143:27)
    at Object.next (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:124:57)
    at /Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:113:16)
    at MongoEntityManager.findByIds (/Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/entity-manager/MongoEntityManager.js:105:38)
    at MongoRepository.findByIds (/Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/repository/MongoRepository.js:51:29)
    at SubjectDatabaseEntityLoader.<anonymous> (/Users/mandaputra/Code/me/sonicjs/node_modules/typeorm/persistence/SubjectDatabaseEntityLoader.js:89:50)
    at step (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:143:27)
    at Object.next (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:124:57)
    at /Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/Users/mandaputra/Code/me/sonicjs/node_modules/tslib/tslib.js:113:16)
[nodemon] app crashed - waiting for file changes before starting...
^C%                                                     

The .env there are no TYPEORM_URL just DATABASE_URL, full .env

MODE=dev
LOCAL_DEV=true
PORT=3018
FRONT_END_THEME=bootstrap5
FRONT_END_THEME_BOOTSWATCH=
ADMIN_THEME=light
RECAPTCHA_SITE_KEY=CHANGEME
SENDGRID_API_KEY=CHANGEME
SENDGRID_PASSWORD=CHANGEME
SENDGRID_USERNAME=CHANGEME
SESSION_SECRET=CHANGEME
CRYPTO_PASSWORD=CHANGEME
SEND_EMAIL=TRUE
ADMIN_DOMAIN=localhost
AMAZONID=CHANGEME
AMAZONSECRET=CHANGEME
ZENCODERKEY=CHANGEME
SESSION_SECRET=CHANGEME
DROPBOX_TOKEN=CHANGEME
BACKUP_URL=backup-CHANGEME
FILE_STORAGE=FILE_SYSTEM

TYPEORM_CONNECTION=mongodb
DATABASE_URL=mongodb://root:admin@localhost:27017/sonicjs?authSource=admin
TYPEORM_HOST=localhost
TYPEORM_USERNAME=root
TYPEORM_PASSWORD=admin
TYPEORM_DATABASE=sonicjs
TYPEORM_PORT=27017
TYPEORM_SYNCHRONIZE=true
TYPEORM_LOGGING=true
lane711 commented 2 years ago

Thanks for the details - I'll test this out asap and get back to you