Skip to content

Instantly share code, notes, and snippets.

@midorikocak
Created December 18, 2021 11:40
Show Gist options
  • Save midorikocak/0cf931443f33baa3fb3f2c6c46c69a34 to your computer and use it in GitHub Desktop.
Save midorikocak/0cf931443f33baa3fb3f2c6c46c69a34 to your computer and use it in GitHub Desktop.
Express model class recap
let artwork = {
id: "1",
name: "Starry Night",
description:
"The Starry Night is an oil-on-canvas painting by the Dutch Post-Impressionist painter Vincent van Gogh. Painted in June 1889, it depicts the view from the east-facing window of his asylum room at Saint-Rémy-de-Provence, just before sunrise, with the addition of an imaginary village.",
format: "Oil on Canvas",
artist: 'Vincent Van Gogh',
year: '1899',
width: "73",
length: "32",
mainImage: "some url",
url: '',
created: "2021-12-18 12:14",
updated: "2021-12-18 12:14",
};
class Artwork {
constructor(id, name, format, artist, year, width, length) {
this.id = id;
this.name = name;
this.format = format;
this.artist = artist;
this.year = year;
this.width = width;
this.length = length;
}
}
let starryNight = new Artwork(1, 'Starry Night', 'Oil on canvas', 'Vincent Van Gogh', '1899', 73, 92)
starryNight.year = '2003'
starryNight.save();
starryNight.year
let dateObject = new Date();
let month = dateObject.getMonth();
let secondsSince1970 = Date.now()
// read
// 1. get by ID - one(id) --- Expect one object with data
// 2. get all items - all() --- Expect array of objects with data
// create
// add(dataObject) --- Shouldn't have an id
// update
// update(dataObject) --- Should have an id
// edit(id, partialData) -- {year: '2003'}
// delete
// delete(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment