Skip to content

Instantly share code, notes, and snippets.

@cklanac
cklanac / challenge-07-single-table.md
Last active November 3, 2018 08:46
Challenge 07: KnexJS with a single table

Noteful Challenge - Postgres/Knex with Single-Table

For this challenge you will clone the Noteful V2 starter and update the app to use knex. The starter is configured to connect to the noteful-app database you created in the previous challenge.

Create a database and table

Before getting started you should have completed the previous challenge where you created a noteful-app database and populated the notes table with sample data.

Requirements

@cklanac
cklanac / challenge-08-one-to-many.md
Last active March 28, 2020 06:52
Challenge 08: One-to-Many

Noteful Challenge - One-to-Many

In this challenge you will create a folders table, create a new router and endpoints for the folders, and update the existing notes endpoints to return folder related data.

Requirements

  • Create a folders table
    • Optionally, alter the default sequence so the folder IDs start at 100
  • Add a folder_id column to the notes table and define the relationship
  • Populate the folders table with sample data and update the notes data to include folders.
@cklanac
cklanac / noteful.js
Last active February 7, 2018 22:10
Noteful V2 One To Many (App with Folders)
/* global $ store api moment*/
'use strict';
const noteful = (function () {
function render() {
const notesList = generateNotesList(store.notes, store.currentNote);
$('.js-notes-list').html(notesList);
const folderList = generateFolderList(store.folders, store.currentQuery);
@cklanac
cklanac / challenge-09-many-to-many.md
Last active June 26, 2024 18:32
Challenge 09: KnexJS with Many-to-Many

Noteful Challenge - Many-to-Many

In this challenge you will create a tags and notes_tags table which will setup a many-to-many relationship between notes and tags. You'll also create a new router to perform CRUD operations on the tags, and update the existing notes endpoints to work with tag related data.

Requirements

Add tags and notes_tags table and relationships

To get started, let's update the .sql script from the previous challenges. Create a tags table and define 2 fields in the schema.

@cklanac
cklanac / server.test.js
Last active April 27, 2018 16:52
Starter test suite for Noteful
'use strict';
/**
* DISCLAIMER:
* The examples shown below are superficial tests which only check the API responses.
* They do not verify the responses against the data in the database. We will learn
* how to crosscheck the API responses against the database in a later exercise.
*/
const app = require('../server');
const chai = require('chai');
@cklanac
cklanac / folders.json
Created February 9, 2018 14:58
Sample Seed Data
[
{"id": 100, "name": "Archive"},
{"id": 101, "name": "Drafts"},
{"id": 102, "name": "Personal"},
{"id": 103, "name": "Work"}
]
@cklanac
cklanac / challenge-12-mongoose.md
Last active November 3, 2018 08:50
Challenge 12: Mongoose

For this challenge you will clone the Noteful V3 starter and add mongoose to your Noteful app, create the endpoints for Notes.

Requirements

  • Install Mongoose
  • Update the config.js file with database connection information
  • Create a notesSchema and Note model
  • Seed the database
  • Create initial queries in scratch file
  • Convert _id to id and remove __v using toObject
@cklanac
cklanac / challenge-13-mongoose-testing.md
Last active November 3, 2018 08:56
Challenge 13: Mongoose Testing

In this challenge you will add integration tests to your API. The goal is to create tests which cover all the correct/positive scenarios as well as tests for negative scenarios such as a 404 Not Found.

Requirements

  • NPM install devDependencies for testing and update package.json file
  • Update server.js to prevent mongoose.connect and app.listen from running during tests
  • Export app for testing
  • Update config.js with the test database URL
  • Create a /test/notes.test.js file and tests for each endpoint
@cklanac
cklanac / challenge-14-relationships-i.md
Last active November 3, 2018 08:45
Challenge 14: Mongo(ose) Relationships

For this challenge, you will add Folders to the Noteful app, associate the notes with the folders, create routes and tests for the folders and update the routes and test for the notes.

Requirements

  • Create folder schema, update notes schema and seed the database
  • Create folder endpoints and update notes endpoints
  • Update server.js mount folder router
  • Update the client

Create/Update schemas and seed the database

@cklanac
cklanac / challenge-15-relationships_ii.md
Last active November 3, 2018 08:55
Challenge 15: Mongo(ose) Relationships II

In this challenge, you will add Tags to the Noteful app, populate the notes with tags, create routes and tests for the tags and update the routes and test for the notes.

Requirements

  • Create tag schema, update notes schema and then seed the database
  • Create tags endpoints and update notes endpoints
  • Update server.js to mount tags router
  • Update the client

Create/Update schemas and seed the database