1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-11-24 23:26:17 +09:00
This commit is contained in:
syuilo 2018-03-28 13:13:10 +09:00
parent e802198b27
commit 73bb57480b
3 changed files with 39 additions and 6 deletions

View File

@ -1,3 +1,13 @@
import * as mongo from 'mongodb';
import db from '../../db/mongodb';
export default db.get('messaging_histories') as any; // fuck type definition
const MessagingHistory = db.get<IMessagingHistory>('messagingHistories');
export default MessagingHistory;
export type IMessagingHistory = {
_id: mongo.ObjectID;
updatedAt: Date;
userId: mongo.ObjectID;
partnerId: mongo.ObjectID;
messageId: mongo.ObjectID;
};

View File

@ -5,16 +5,17 @@ import { pack as packFile } from './drive-file';
import db from '../../db/mongodb';
import parse from '../common/text';
const MessagingMessage = db.get<IMessagingMessage>('messaging_messages');
const MessagingMessage = db.get<IMessagingMessage>('messagingMessages');
export default MessagingMessage;
export interface IMessagingMessage {
_id: mongo.ObjectID;
created_at: Date;
createdAt: Date;
text: string;
user_id: mongo.ObjectID;
recipient_id: mongo.ObjectID;
is_read: boolean;
userId: mongo.ObjectID;
recipientId: mongo.ObjectID;
isRead: boolean;
fileId: mongo.ObjectID;
}
export function isValidText(text: string): boolean {

View File

@ -79,3 +79,25 @@ db.following.update({}, {
follower_id: 'followerId',
}
}, false, true);
db.messaging_histories.renameCollection('messagingHistories');
db.messagingHistories.update({}, {
$rename: {
updated_at: 'updatedAt',
user_id: 'userId',
partner: 'partnerId',
message: 'messageId',
}
}, false, true);
db.messaging_messages.renameCollection('messagingMessages');
db.messagingMessages.update({}, {
$rename: {
created_at: 'createdAt',
user_id: 'userId',
recipient_id: 'recipientId',
file_id: 'fileId',
is_read: 'isRead'
}
}, false, true);