Skip to content

Instantly share code, notes, and snippets.

View sandrabosk's full-sized avatar
👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall

Aleksandra Bošković sandrabosk

👩‍💻
Always a student, never a master. Have to keep moving forward. ~C.Hall
  • Ironhack
View GitHub Profile

User authentication (login) workflow

User registration (sign up) workflow

// ************************************************************************************
// https://www.codewars.com/kata/54b724efac3d5402db00065e
// In this kata you have to write a simple Morse code decoder. While the Morse code is
// now mostly superseded by voice and digital data communication channels, it still has
// its use in some applications around the world.
// The Morse code encodes every character as a sequence of "dots" and "dashes".
// For example, the letter A is coded as ·−, letter Q is coded as −−·−, and digit 1 is
// coded as ·−−−−. The Morse code is case-insensitive, traditionally capital letters are
// used. When the message is written in Morse code, a single space is used to separate

Basic use of the .populate() Mongoose method

The pattern for using .populate():

router.get('/list', (req, res, next) => {
  Model
    // prettier-ignore
    .find()
 .populate('property1')
// ************************************************************************************
// https://www.codewars.com/kata/5822d89270ca28c85c0000f3/javascript
// Given a string and an array of index numbers, return the characters of the string
// rearranged to be in the order specified by the accompanying array.
// Ex:
// scramble('abcd', [0,3,1,2]) -> 'acdb'
// The string that you will be returning back will have: 'a' at index 0, 'b' at index 3,
const contacts = [
{
name: 'Idris Elba',
pictureUrl: 'https://image.tmdb.org/t/p/w500/d9NkfCwczP0TjgrjpF94jF67SK8.jpg',
popularity: 11.622713,
id: '11731993-0604-4bee-80d5-67ad845d0a38'
},
{
name: 'Jessica Chastain',
pictureUrl: 'https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/upload_13fb5a5c4c481562327cad9f6de1bd00.png',
// How would you get the value of queries and params in the following examples?
// PARAMS:
// 1:
// https://dummyexample.com/albums/123cool4lbum
app.get('/albums/:albumId', (req, res) => {
console.log( /* your code goes here */)
})

Seed mLab from a dev database

Your MONGODB_URI should look somewhat like this:

mongodb://heroku_3vf5zhlq:[email protected]:41218/heroku_3vf5zhlq

where this is the pattern:

mongodb://user:pass@host:port/db