created a 2nd, temporary, strapi app that is successfully using mongodb from the start (so I have a good mongo instance running locally)
copied the database.json content from the temp, working-mongodb, strapi app to my existing one. (made sure was in development and ran development version)
From my existing app (from which I want to use mongodb), I
uninstalled:
strapi-hook-bookshelf
strapi-hook-knex
knex
sqlite3
installed strapi-hook-mongoose
(node:37499) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:37499) UnhandledPromiseRejectionWarning: TypeError: orm.load(...).buildQuery is not a function
at buildQuery (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-utils/lib/buildQuery.js:122:21)
at Object.count (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/config/queries/mongoose.js:18:12)
at Object.initialize (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/services/UsersPermissions.js:502:8)
at module.exports (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/config/functions/bootstrap.js:156:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:37499) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:37499) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[2019-07-03T18:27:15.985Z] warn The bootstrap function is taking unusually long to execute (3500 miliseconds).
[2019-07-03T18:27:15.986Z] warn Make sure you call it?
What am I doing wrong? 🤔
If you want to safely store your Strapi content in MongoDB, sign up for MongoDB Atlas for free. Happy content creation!
Strapi supports both NoSQL and SQL databases. Changing the database is as simple as changing the env variable in the configuration folder. By default, Strapi uses SQLite, which is good for local testing, but in production you should use a production-ready database such as PostgreSQL or MySQL. We'll use PostgreSQL here.
This is cool! I can answer my own question! 😜
Seriously though, I am answering my own question for the benefit of others that might run into the same issue.
Bottom line: I had the wrong version of strapi-hook-mongoose
installed.
Details: When I installed strapi-hook-mongoose
, I didn't specify a version, and so, npm installed ^3.0.0-alpha.13
, and due to the fact that my existing, strapi project is on the (then) latest v3.0.0-beta.7
, it failed to run (gave the error described in the above description).
Solution: Uninstall the package and re-install, explicitly specifying the version 👇
npm i [email protected]
🙌
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With