Appearance
Database Setup
FreshSource: shipfa.st/docs/features/database
Procedure
- Create a new project and deploy a cluster on MongoDB Atlas
TIP
Run a local database for dev -- works offline and is faster.
In MongoDB Atlas, click Network Access > + Add IP Address. Enter
0.0.0.0/0to allow connections from anywhere (dev + production).Add your connection string to
MONGODB_URIin.env.local.
Mongoose (Optional)
Mongoose makes MongoDB easier with schema validation and plugins.
- Models are in the
/modelsfolder - The
toJSONplugin removes_idand__vfrom responses - Add
private: trueto any field to exclude it from API responses
javascript
// Example: email won't be sent to frontend
const UserSchema = new Schema({
name: String,
email: { type: String, private: true },
hasAccess: { type: Boolean, default: false }
});Verification Checklist
- [ ] MongoDB Atlas cluster created
- [ ] IP whitelist set to 0.0.0.0/0
- [ ] MONGODB_URI added to .env.local
- [ ] Can connect from localhost