35
loading...
This website collects cookies to deliver better user experience
For latest updates on Strapi and MongoDB, please reference this blog post.
yarn create strapi-app my-project //using yarn
npx create-strapi-app my-project //using npx
my-project
with the name you wish to call your application directory. Your package manager will create a directory with the name and will install Strapi.yarn develop //using yarn
npm run develop //using npm
http://localhost:1337/admin
.collection types
, and these are similar to models or schema in a database. A collection type has fields that are like properties. Strapi offers a wide range of options for fields, including Text, Short Text, Relations, and many more.Plugins
section, which contains the content-type
builder and the media library.
The Content Builder allows users to create different content types, while the Media Library contains all the media uploads done by users.General
section, which has the marketplace
, the plugins
, and settings
. The settings
section allows us to set the user permissions, roles, and many more essential functions.API
section (directory) contains the different Content-Type present in our Application. It has a code to edit depending on what goals we plan to achieve with our Application. note
and then click Continue.Text
, name the field title
, leave the type selection as Short Text
, and add another field.Rich Text
, name the field content
, then click on add another fieldJSON
, name the field Editors
, then click on add another fieldRelations
, and then click on the dropdown that's on the right side of the popup window, select User (from: users-permissions-user)
, then click on Users have many notes. It should look like the image below.GENERAL
in the side menuCount and Find
.findOne
and me.Create a Mongo DB account on the MongoDb website.
Create a Project and a Cluster
Click on Create a new Project
.
Then click Build a Cluster
, from the options page:
MO
.Click the green Create Cluster
button.
Under Overview
click on the Database Access
in the left menu :
+ ADD NEW USER
button:
username
.password
.User Privileges
ensure Read and write to any database
is selected. Then click Add User
.Click on Network Access
, under Security
in the left menu:
+ ADD IP ADDRESS
ADD CURRENT IP ADDRESS
or manually enter in an IP address to whitelist
.0.0.0.0/0
in the Whitelist Entry
.Anywhere
.Confirm
. Then wait until the status turns from Pending
to Active
.Retrieve database credentials
In order to retrieve your database credentials do the following:
Atlas
in the left-hand, click on Clusters
.
CONNECT
and then Connect Your Application
.1. Choose your driver version
, select DRIVER
as Node.js
and VERSION
as 3.6 or later
.CONNECTION STRING
should be similar to this:mongodb+srv://alecGodwin<password>@cluster0.5gjqw.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
<password>
with your Mongo DB Atlas password.Open up your config/database.js
file and add the following lines of code
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'mongoose',
settings: {
uri: env('DATABASE_URI'),
},
options: {
ssl: true,
},
},
},
});
Open up your .env
file then add your connection string
from instruction 5 as your DATABASE_URI
.
yarn create nuxt-app <project-name> //using yarn
npx create-nuxt-app <project-name> //using npx
npm init nuxt-app <project-name> //using npm
cd <project-name
yarn dev //using yarn
npm run dev //using npm
[http://localhost:3000](http://localhost:3000)
.35