« first day (1331 days earlier)      last day (1327 days later) » 

12:44 AM
BUTTS
 
 
2 hours later…
m59
2:21 AM
I did watch it before, and I'm watching it again
Whenever I hear this stuff, I end up with the same conclusion - relational data is too coupled
Specific example: it seems like if you asked a thing for a post, you should be able to get a post
However, if I removed the comment table altogether, then the post query breaks
 
@m59 if you used a document store, and sometimes there were comments and sometimes there weren't, you are essentially maintaining two schemas
 
m59
oops, that was wrong. Bad example. It would be the other way around.
 
data is usually relational
and more importantly, when you need to query for it, the relationships are usually what you're concerned with
 
 
16 hours later…
m59
6:57 PM
I'm not finding Knex all that useful.
SELECT
          story_comment.id,
          story_comment.story_id,
          story_comment.user_id,
          story_comment.body,
          story_comment.time_submitted,
          user.first_name,
          user.last_name,
          user.user_name,
          COUNT(story_comment_vote.id)        AS score,
          MAX(story_comment_vote.user_id = ?) AS user_voted,
          MAX(story_comment_flag.user_id = ?) AS user_flagged,
          IF(user_avatar.id IS NULL, null, CONCAT('/api/users/userName=',user.user_name,'/avatar')) AS user_avatar_src
I'm not sure if .max('story_comment_vote.user_id = ? AS user_voted') will even work
but that IF part...I can't see anyway I pulling that off.
Maybe I should just write my own.
 
 
1 hour later…
8:07 PM
@m59 if it's using prepared statements, then sadly prepared statements don't let you insert values in the SELECT part of the query
 
m59
It turns out that .max and .count are seemingly kinda useless
you can just put whatever you want in the select
 
 
3 hours later…
m59
11:36 PM
SELECT
  `story_comment`.id,
  `story_comment`.thread_id,
  `story_comment`.author_id,
  `story_comment`.body,
  `story_comment`.time_submitted,
  COUNT(`story_comment_vote`.id)                   AS score,
  MAX(`story_comment_vote`.voter_id = 14)   AS viewer_voted,
  MAX(`story_comment_flag`.flagger_id = 14) AS viewer_flagged

FROM `story_comment`
JOIN `user`           ON `user`.`id`  = `story_comment`.author_id
LEFT JOIN story_comment_vote ON `story_comment_vote`.comment_id = `story_comment`.id
everywhere there's backticks, those values were inserted using node-mysql's escapeId function
this is safe, right?
those would never be from a user - the question is more just to check my understanding
 
@m59 yeah, enclosing identifiers in backticks is correct
 
m59
I'm just new to the idea of not using prepared statements...
kinda freakin' me out is all.
 
shouldn't really be necessary if your tables are all named simply and reasonably, but it sure doesn't hurt
identifiers can be pretty much anything
they can even contain backticks :-)
 
m59
I'm idiotically still trying to do this dynamic table stuff.
 
ah, comments in all different tables?
That seems like a mistake :-x
 
m59
11:40 PM
I dunno what you just said ;D
Say you have two kind of things you need comment systems for
var comments = require('comments');
comments.init('posts', {
  table: 'post_comment'
});
comments.init('something_else', {
  table: 'something_else_comment'
});
The actual settings require more related table names and column names, but it's not bad.
This is a terrible idea, isn't it? It ends up being an ORM, I guess.
But otherwise you end up with two systems that are otherwise identical but relate to different things!
that's terrible.
maybe the solution to that is to add another table or another column to keep up with something which I can't presently think of...
I guess a namespace column
eh, I don't think that would work at all
FK's would be useless.
 

« first day (1331 days earlier)      last day (1327 days later) »