From 02be56cfc0feaa6dad6a63759eeae0ec7dfbfff4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 15:54:47 +0900 Subject: [PATCH] wip --- src/api/models/othello-matching.ts | 8 ++++---- src/api/models/poll-vote.ts | 12 +++++++++++- tools/migration/shell.camel-case.js | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/api/models/othello-matching.ts b/src/api/models/othello-matching.ts index 5cc39cae1..9c84d7fb9 100644 --- a/src/api/models/othello-matching.ts +++ b/src/api/models/othello-matching.ts @@ -3,14 +3,14 @@ import deepcopy = require('deepcopy'); import db from '../../db/mongodb'; import { IUser, pack as packUser } from './user'; -const Matching = db.get('othello_matchings'); +const Matching = db.get('othelloMatchings'); export default Matching; export interface IMatching { _id: mongo.ObjectID; - created_at: Date; - parent_id: mongo.ObjectID; - child_id: mongo.ObjectID; + createdAt: Date; + parentId: mongo.ObjectID; + childId: mongo.ObjectID; } /** diff --git a/src/api/models/poll-vote.ts b/src/api/models/poll-vote.ts index af77a2643..3e883f213 100644 --- a/src/api/models/poll-vote.ts +++ b/src/api/models/poll-vote.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('poll_votes') as any; // fuck type definition +const PollVote = db.get('pollVotes'); +export default PollVote; + +export interface IPollVote { + _id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; + postId: mongo.ObjectID; + choice: number; +} diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 11c6fe401..6045dfa00 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -130,3 +130,20 @@ db.othelloGames.update({}, { } }, false, true); +db.othello_matchings.renameCollection('othelloMatchings'); +db.othelloMatchings.update({}, { + $rename: { + created_at: 'createdAt', + parent_id: 'parentId', + child_id: 'childId' + } +}, false, true); + +db.poll_votes.renameCollection('pollVotes'); +db.pollVotes.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId' + } +}, false, true);