@@ -2,13 +2,13 @@ const Snippet = require('../../../model/snippet');
2
2
3
3
const NotFoundError = require ( '../../../error/not-found.error' ) ;
4
4
5
- const CodeletInputValidator = require ( './snippet-input.validator' ) ;
5
+ const SnippetInputValidator = require ( './snippet-input.validator' ) ;
6
6
7
7
/**
8
8
* CREATE snippet for user
9
9
*/
10
10
let createSnippet = async function ( userId , snippetData ) {
11
- CodeletInputValidator . validateSnippetInput ( userId , snippetData ) ;
11
+ SnippetInputValidator . validateSnippetInput ( userId , snippetData ) ;
12
12
13
13
const snippet = new Snippet ( snippetData ) ;
14
14
let newSnippet = await snippet . save ( ) ;
@@ -52,24 +52,24 @@ let getAllMySnippets = async (userId) => {
52
52
* full UPDATE via PUT - that is the whole document is required and will be updated
53
53
* the descriptionHtml parameter is only set in backend, if only does not come front-end (might be an API call)
54
54
*/
55
- let updateSnippet = async ( userId , codeletId , codeletData ) => {
55
+ let updateSnippet = async ( userId , codeletId , snippetData ) => {
56
56
57
- CodeletInputValidator . validateSnippetInput ( userId , codeletData ) ;
57
+ SnippetInputValidator . validateSnippetInput ( userId , snippetData ) ;
58
58
59
- const updatedCodelet = await Snippet . findOneAndUpdate (
59
+ const updatedSnippet = await Snippet . findOneAndUpdate (
60
60
{
61
61
_id : codeletId ,
62
62
userId : userId
63
63
} ,
64
- codeletData ,
64
+ snippetData ,
65
65
{ new : true }
66
66
) ;
67
67
68
- const codeletNotFound = ! updatedCodelet ;
69
- if ( codeletNotFound ) {
70
- throw new NotFoundError ( 'Snippet NOT_FOUND with id: ' + codeletId + ' AND title: ' + codeletData . title ) ;
68
+ const snippetNotFound = ! updatedSnippet ;
69
+ if ( snippetNotFound ) {
70
+ throw new NotFoundError ( 'Snippet NOT_FOUND with id: ' + codeletId + ' AND title: ' + snippetData . title ) ;
71
71
} else {
72
- return updatedCodelet ;
72
+ return updatedSnippet ;
73
73
}
74
74
} ;
75
75
0 commit comments