Mongoose Model

Mongoose Model 環境設定 這是這次實驗用的 code const mongoose = require('mongoose'); mongoose.connect('mongodb://127.0.0.1:27017', {useNewUrlParser: true, useUnifiedTopology: true}) .then(() => console.log('Connected to DB')) .catch(e => console.error(e)); const requiredString = { type: String, required: true } const UserSchema = new mongoose.Schema({ username: requiredString, password: requiredString }); const UserModel = mongoose.model('User', UserSchema); mongo db 用 docker 開一個實驗用的 server version: '3' services: db: image: 'mongo' container_name: 'aurl-mongodb' volumes: - ....

2020-November-10 · 1 分鐘 · simba-fs