【发布时间】:2016-11-20 16:41:30
【问题描述】:
我正在编写一个使用 Google Datastore 的 Nodejs 应用程序。我只想知道如何使用谷歌数据存储为身份验证过程设置架构。基本上,我如何使用 Google Datastore 执行 下面的代码:
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
var userSchema = mongoose.Schema({
local : {
email : String,
password : String,
}
});
// generating a hash
userSchema.methods.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};
// checking if password is valid
userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.local.password);
};
// create the model for users and expose it to our app
module.exports = mongoose.model('User', userSchema);
我刚开始使用 Nodejs 和 Google Datastore,如果这个问题看起来很基础,我很抱歉。
【问题讨论】:
标签: node.js google-app-engine express google-cloud-datastore nosql