DONE AGAIN
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
//const data = require('../repositories/data.json')
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
@@ -95,10 +94,10 @@ class NotesService {
|
||||
* @param data
|
||||
* @returns {Promise<*|{result: null, data: *[], query: null, message: string, type: string, status: string}>}
|
||||
*/
|
||||
async insertNote( data ){
|
||||
async insertNote (data) {
|
||||
|
||||
const notes = this.db.sort((a, b) => new Date(a.id) > new Date(b.id) ? -1 : 1)
|
||||
data.id = ( notes.length >= 1 ) ? notes[0].id + 1 : 1
|
||||
data.id = (notes.length >= 1) ? notes[0].id + 1 : 1
|
||||
this.db.push(data)
|
||||
await this.saveDatabase()
|
||||
|
||||
@@ -110,11 +109,11 @@ class NotesService {
|
||||
* @param data
|
||||
* @returns {Promise<*|{result: null, data: *[], query: null, message: string, type: string, status: string}>}
|
||||
*/
|
||||
async updateNote( data ){
|
||||
async updateNote (data) {
|
||||
|
||||
const noteExists = this.db.find(note => note.id === +data.id)
|
||||
|
||||
if( noteExists ){
|
||||
if (noteExists) {
|
||||
noteExists.title = data.title
|
||||
noteExists.content = data.content
|
||||
noteExists.category = data.category
|
||||
@@ -127,7 +126,6 @@ class NotesService {
|
||||
|
||||
return this._composeResponse([], `UPDATED WHERE id = ${data.id}`)
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user