Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update QUERIES.md #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion QUERIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ def getPluckQuery(properties):
//Get the top three entries
r.db('rethinkdb_workshop').table('reddit').orderBy({ index: r.desc('superScore') }).limit(3).changes()
// Add the pluck again
r.db('rethinkdb_workshop').table('reddit').orderBy({ index: r.desc('superScore') }).limit(3).changes().pluck('title', 'score')
r.db('rethinkdb_workshop').table('reddit').orderBy({ index: r.desc('superScore') }).limit(3).changes()('new_val').pluck('title', 'score')
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Complete all 5 steps to get the chat app working. Each step will involve writing

1. Sign up: [/server/auth/authcontroller.js:L20](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/auth/auth-controller.js#L20)
2. Login (2.1 and 2.2): [/server/auth/index.js:L28 and L29](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/auth/index.js#L28)
3. Inserting messages: [/server/index.js:116](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/index.js#L138)
3. Inserting messages: [/server/index.js:116](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/index.js#L124)
4. Getting messages: [/server/index.js:L55](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/index.js#L76)
5. Listening for messages: [/server/index.js:L90](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/index.js#L110)
5. Listening for messages: [/server/index.js:L90](https://github.com/thejsj/rethinkdb-workshop/blob/master/server/index.js#L103)

After completing these 5 steps, your chat app will run correctly.

Expand Down
8 changes: 0 additions & 8 deletions server/auth/auth-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ authController.signup = function (req, res) {
* to sign up in the front-end and see the registered user
* in the database. You won't be able to sign in.
*/
return r.branch(
r.table('users').get(email),
false,
r.table('users').insert({
email: email,
password: hash
})
).run(r.conn);
})
.then(function (result) {
if (!result) res.send('User already exists');
Expand Down
25 changes: 0 additions & 25 deletions server/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ passport.deserializeUser(function (email, done) {
* Once you complete the 2 queries in this file, you'll be able to
* log in to the site.
*/
r
.table('users')
.get(email)
.run(r.conn)
.then(function (user) {
done(null, user);
});
});

// Local
Expand Down Expand Up @@ -76,24 +69,6 @@ passport.use(new LocalStrategy({
* After completing step 2.1 and this step, you'll be able
* to login with the created account.
*/
r.table('users')
.get(email)
.run(r.conn)
.then(function (user) {
if (!user || user === null) {
done(null, false);
return;
}
return doPasswordsMatch(password, user.password)
.then(function (isMatch) {
if (!isMatch) {
done(null, false);
return;
}
done(null, user);
});
})
.catch(done);
}
));

Expand Down
19 changes: 0 additions & 19 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ app
* Once you have written this query, you'll be able to see
* all previously inserted messages when loading the page
*/
r.table('messages')
.orderBy({index: 'created'})
.coerceTo('array')
.run(r.conn)
.then(function (messages) {
res.json(messages);
});
})
.use('/config.js', clientConfigParser)
.get('/', function (req, res) {
Expand Down Expand Up @@ -124,13 +117,6 @@ io.on('connection', function (socket) {
* once you write this query, you'll be able to see new messages be displayed
* as they are being added
*/
r.table('messages')
.changes().run(r.conn)
.then(function(cursor) {
cursor.each(function (err, row) {
socket.emit('message', row.new_val);
}, function () { });
});

// Insert new messages
socket.on('message', function (data) {
Expand All @@ -155,11 +141,6 @@ io.on('connection', function (socket) {
* Once you write this query, you'll be able to insert new
* messages in the front-end and see them in the database
*/
r.table('messages').insert({
text: data.text,
email: data.email,
created: (new Date()).getTime()
}).run(r.conn);
});

});