怎么把mlab变成atlas?

时间:2019-05-15 22:34:25

标签: mongodb express mongoose mongodb-atlas

我有一个使用mlab的应用程序,我看到的唯一与mlab相关的地方是我的环境变量。

我没有要保存的任何数据。

所以,我想知道我唯一需要更改的是环境变量吗?

这是我的用户模型:

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
const md5 = require('md5');
const validator = require('validator');
const mongodbErrorHandler = require('mongoose-mongodb-errors');
const passportLocalMongoose = require('passport-local-mongoose');
const slug = require('slugs');

const userSchema = new Schema({
  email: {
    type: String,
    unique: true,
    lowercase: true,
    trim: true,
    validate: [validator.isEmail, 'Invalid Email Address'],
    required: 'Please Supply an email address'
  },
  name: {
    type: String,
    required: 'Please supply a name',
    trim: true
  },
  resetPasswordToken: String,
  resetPasswordExpires: Date,
  props: [
    { type: mongoose.Schema.ObjectId, ref: 'User' }
  ],
});

userSchema.plugin(passportLocalMongoose, { usernameField: 'email' });
userSchema.plugin(mongodbErrorHandler);

module.exports = mongoose.model('User', userSchema);

0 个答案:

没有答案