小编Vik*_*Vik的帖子

如何使用Google数据存储区(在javascript中)创建架构?

我正在编写一个使用Google Datastore的Nodejs应用程序.我只想知道如何使用google数据存储区为身份验证过程设置架构.基本上,我如何使用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);
Run Code Online (Sandbox Code Playgroud)

我刚刚开始使用Nodejs和Google Datastore,所以如果这个问题看起来很基本,我很抱歉.

google-app-engine nosql node.js express google-cloud-datastore

2
推荐指数
1
解决办法
812
查看次数