0

I started with monk instead of mongoose - and I really would be happy to stay this way!

My concrete problem: How to transfer or better 'adapt' this following functionalities - that exists in a lot of node/mongoose/passport.js tutorials - with monk?

This is the snippet for mongoose:


// app/models/user.js

var mongoose = require('mongoose');
var bcrypt   = require('bcrypt-nodejs');

// define the schema for our user model

var userSchema = mongoose.Schema({..})

// 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);

Well I have a monk schema already, but how to go on? Could anybody gives me a hint to have an equivalent for the two bcrypt functionalities and model creation & backpassing with monk?

Vishnu
  • 11,614
  • 6
  • 51
  • 90
maxxyoo
  • 123
  • 1
  • 1
  • 5
  • Why you need a equivalent of bcrypt functions? Basically you just changed the mongodb api. The logic still the same. – Alvaro Silvino Sep 08 '15 at 21:33
  • I think this post will help you: http://stackoverflow.com/questions/23615377/monk-vs-mongoose-for-mongodb – Alvaro Silvino Sep 08 '15 at 21:41
  • Yes, I know this post already. I have no intentions to use pure mongodb, I like the idea of monk as layer. ..and if mongoose offers solution as ".model" creation and "instance methods" I would like to know how to with monk - except of cource this is no playground for monk? – maxxyoo Sep 08 '15 at 21:47

0 Answers0