Step 4

Create a subfolder data (inside the server folder). Add the file NoteDao.js to this folder, with the following content:

const Note = require("../model/Note");

class NoteDao {

  async create ({ title, text }) {

  }

  async update (id, { title, text }) {
    
  }

  async delete (id) {
    
  }

  async read (id) {
    
  }

  async readAll (query = "") {
    
  }
}

module.exports = NoteDao;

Notice the NoteDao provides CRUD operations. This class is a Data Access Object (DAO) for Note.

In a nutshell, a DDAO is an object that provides an abstraction over some database or other persistence mechanisms.

We will enetually store the notes in a database. For now, however, let's store them in an array!

  class NoteDao {
+   constructor() {
+     this.notes = [];
+   }

Save and commit the changes.