Skip to content
Permalink
Browse files

chp 2

  • Loading branch information...
somaditya committed Mar 3, 2019
1 parent 20bbdde commit 2de51670df2fc10b2f12d5f594c86e88d86bf020
Showing with 11 additions and 7 deletions.
  1. +1 −1 build/index.html
  2. +3 −0 src/dao/moviesDAO.js
  3. +7 −6 src/dao/usersDAO.js
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet"><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"><title>mflix</title><script>window.mflix={useFacets:!1}</script><link href="/static/css/main.d2c98b4b.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={2:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.85042e97.chunk.js"></script><script src="/static/js/main.81b71a0a.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet"><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"><title>mflix</title><script>window.mflix={useFacets: true}</script><link href="/static/css/main.d2c98b4b.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={2:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.85042e97.chunk.js"></script><script src="/static/js/main.81b71a0a.chunk.js"></script></body></html>mflix
@@ -195,6 +195,9 @@ export default class MoviesDAO {
const queryPipeline = [
matchStage,
sortStage,
skipStage,
limitStage,
facetStage
// TODO Ticket: Faceted Search
// Add the stages to queryPipeline in the correct order.
]
@@ -39,7 +39,7 @@ export default class UsersDAO {
static async getUser(email) {
// TODO Ticket: User Management
// Retrieve the user document corresponding with the user's email.
return await users.findOne({ someField: "someValue" })
return await users.findOne({ "email": email })
}

/**
@@ -60,7 +60,7 @@ export default class UsersDAO {
// Insert a user with the "name", "email", and "password" fields.
// TODO Ticket: Durable Writes
// Use a more durable Write Concern for this operation.
await users.insertOne({ someField: "someValue" })
await users.insertOne({ "name": userInfo.name, "email": userInfo.email, "password": userInfo.password })
return { success: true }
} catch (e) {
if (String(e).startsWith("MongoError: E11000 duplicate key error")) {
@@ -83,8 +83,9 @@ export default class UsersDAO {
// Use an UPSERT statement to update the "jwt" field in the document,
// matching the "user_id" field with the email passed to this function.
await sessions.updateOne(
{ someField: "someValue" },
{ $set: { someOtherField: "someOtherValue" } },
{ "user_id": email },
{ $set: { "jwt": jwt } },
{ upsert: true}
)
return { success: true }
} catch (e) {
@@ -102,7 +103,7 @@ export default class UsersDAO {
try {
// TODO Ticket: User Management
// Delete the document in the `sessions` collection matching the email.
await sessions.deleteOne({ someField: "someValue" })
await sessions.deleteOne({ "email": email })
return { success: true }
} catch (e) {
console.error(`Error occurred while logging out user, ${e}`)
@@ -120,7 +121,7 @@ export default class UsersDAO {
try {
// TODO Ticket: User Management
// Retrieve the session document corresponding with the user's email.
return sessions.findOne({ someField: "someValue" })
return sessions.findOne({ "email": email })
} catch (e) {
console.error(`Error occurred while retrieving user session, ${e}`)
return null

0 comments on commit 2de5167

Please sign in to comment.
You can’t perform that action at this time.