Comments (14)
Is there any update on this?
from jugglingdb.
I am seeing this issue as well
User.beforeCreate = function(next){
this.salt = crypto.createHmac('sha1', (new Date().getTime()) +' ').digest('hex');
this.password = crypto.createHmac('sha1', this.salt).update(this.password).digest('hex');
next();
}
but when I check the db the password is still plain text, if I do the hook as beforeSave it is fine though. But I can't use that because if I do one single callback of beforeSave the first save does not give true when I check the propertyChanged('password').
from jugglingdb.
In my case, beforeSave only works when I update a record. When I create a new record, beforeSave does not appear to fire neither.
But beforeSave won't work because I don't want to update my date_created time stamp in this case when this is just an update operation.
It will be nice that this is fixed. I have verified that my hook is fired. But the data are not passed to the abstract_class.js and hence the db adapter class.
from jugglingdb.
Any update on this?
from jugglingdb.
i meet this issue as well, i found this page from google and found it is unresolved...
at last, i found how to resolve...
in abstract-class.js, we can change like this:
AbstractClass.create = function (data, callback) {
if (stillConnecting(this.schema, this, arguments)) return;
var modelName = this.modelName;
if (typeof data === 'function') {
callback = data;
data = {};
}
if (typeof callback !== 'function') {
callback = function () {};
}
var obj = null;
// if we come from save
if (data instanceof AbstractClass && !data.id) {
obj = data;
data = obj.toObject(true);//<-- you can comment this statement
this.prototype._initProperties.call(obj, data, false);
create();
} else {
obj = new this(data);
data = obj.toObject(true);//<-- you can comment this statement
// validation required
obj.isValid(function (valid) {
if (!valid) {
callback(new Error('Validation error'), obj);
} else {
create();
}
});
}
function create() {
obj.trigger('create', function (done) {
var data = this.toObject(true);//<-- add this statement here, so _adapter can get the latest data
this._adapter().create(modelName, data, function (err, id) {
if (id) {
defineReadonlyProp(obj, 'id', id);
addToCache(this.constructor, obj);
}
done.call(this, function () {
if (callback) {
callback(err, obj);
}
});
}.bind(this));
});
}
};
from jugglingdb.
Yes, you did it! That line fixes the issue. Thanks!
from jugglingdb.
has this been submitted for a pull request I do not see it in the current version of the source.
from jugglingdb.
Please somebody reopen this. It's still present and the by5739 patch works well! Make a pull please!
from jugglingdb.
@by5739 , would you mind making a pull for this please? If not, please send me some more details of yourself such as your name, etc so that we can give you credit for the fix in the pull request. If you pick up the fix from somewhere, please provide reference so that we can give credit the proper original owner of the fix.
I can try to issue a pull request on your behalf. I am kind of new to github. But I will try to make this work. Thanks.
from jugglingdb.
@lforge , thank you! I am a beginner of git, i have pull this issue, but i don't know is it enough? see from this: #87
from jugglingdb.
What a pull request mean is that you fork the original code, make your change, then you can push your code back to your own github repository, then you can send the original author a pull request so that the original author can incorporate your change. Hope I explain this correctly. Like I said, I am kind of new to this. Anyway, I will check into this this weekend and see if I can make a pull request on this. Thanks.
from jugglingdb.
@lforge Thank you for telling me how to do that, hope you to make a pull for this, Thanks
from jugglingdb.
Just issue a pull request for this. Let's see if this makes it to the master version. Thanks.
from jugglingdb.
Good!
from jugglingdb.
Related Issues (20)
- README documentation references are not reachable
- is this project dead ? HOT 5
- Potentially unhandled rejection [2] TypeError, when upgrading to new version of node. HOT 1
- Site down HOT 2
- Support multiple hooks per action
- Validations should be revisited
- Deprecate mutation features
- Consider removing all instance methods
- Disallow mixins on Model
- Model relations
- how to query field in multiple values? HOT 1
- Can i use JugglingDB in production? HOT 4
- process rpc message error TypeError: User.bulkUpdate is not a function HOT 2
- How can i delete one record ?
- Is this project maintained? HOT 2
- How to get the table definition from a datasource?
- upsert method doesn't trigger any hooks for mysql adapter HOT 3
- In
- Use in production? HOT 2
- Composite primary keys / composite foreign keys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jugglingdb.