Model class prototype is undefined
See original GitHub issueHi. first of all thank you for this awesome library - it’s amazing! 👍
I wanted to add custom method to the model class, but I’m having problems with accessing to ‘prototype’ property - it’s undefined. Just followed manual, the code below is actually copied over from the doc:
var Sequelize = require('sequelize');
db = new Sequelize('test', 'root', '', {
host: 'localhost',
dialect: 'mysql'
});
db.authenticate()
.then(function(err) {
debug('Connection has been established successfully.');
})
.catch(function (err) {
debug('Unable to connect to the database:', err);
process.exit();
});
var User = db.define('user', { firstname: Sequelize.STRING });
// Adding a class level method
User.classLevelMethod = function() {
return 'foo';
};
// Adding an instance level method
User.prototype.instanceLevelMethod = function() { // <---- HERE
return 'bar';
};```
I have no idea WHY it's undefined... :| To me it looks like not up to date manual or some bug.
sequelize: 3.23.6
nodejs: 6.2.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why is JavaScript prototype property undefined on new objects?
Because prototype is a property of functions (actually, constructors), since it defines the properties/methods of objects of this class ...
Read more >Inheritance and the prototype chain - JavaScript | MDN
While classes abstract most of the prototypical mechanism away, ... undefined, because d doesn't inherit from Object.prototype
Read more >Prototype in JavaScript - TutorialsTeacher
The prototype is an object that is associated with every functions and objects by default in JavaScript, where function's prototype property is accessible ......
Read more >Javascript Prototype & Scope Chains: What You Need to Know
When using prototypal inheritance, remember to define properties in the prototype after having either inherited from the parent class or specified an ...
Read more >Prototype in JavaScript: it's quirky, but here's how it works
[[Prototype]]: This is a somehow-hidden property on every object which is accessed by the running context if some property which is being read ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The docs are for 4.0 - for 3.0, you need to do `User.Instance.prototype
@janmeier you’re f*** right, sorry :<