balderdashy / balderdashy/sails
toJson is not working?
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Sails version**: 1.0.2
**Node version**: 8.12.0
**NPM version**: 6.4.1
**DB adapter name**: sails-mysql
**DB adapter version**: N/A
**Operating system**: windows 10
Hello,
I am using sails version 1.0.2. It encounted an error when i add my toJson function in model. I have already searched to fix this issue. But i don't find any solution. And i am very new to nodejs and sailsjs. Here is the code:
```
module.exports = {
attributes: {
name:{
type: "string",
required: true
},
title:{
type: "string",
},
email:{
type: "string",
// email: true,
required: true,
unique: true
},
encryptedPassword:{
type: "string",
},
toJson: function(){
var obj = this.toObject();
delete obj.password;
delete obj.confirmation;
delete obj.encryptedPassword;
delete obj._csrf;
return obj;
}
}
};
```
> In the toJson attribute of model users:
> Model instance methods are no longer supported in Sails v1.
> Please refactor the logic from this instance method into
> a static method, model method or helper.
Contributor guide
Research direction
Start with the Users model definition shown in the issue and the Sails v1 error message; verify how the `toJson` entry is interpreted in model attributes. Done means reproducing the error and confirming the supported approach for this serialization logic; no test file or repository entry point is identified in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100