<commit_before>import * as mongodb from 'mongodb';
import { BaseDataService } from './BaseDataService'

export class RoomDataService extends BaseDataService{
    public getRoomList(): Promise<any[]> {
        return this.connectToDB().then((db) => {
            let rooms = db.collection('rooms');
            return rooms.find({}).toArray();
        });
    }

    public getRoom(id: string) {
        return this.connectToDB().then((db) => {
            let rooms = db.collection('rooms');
            return rooms.findOne({
                _id: new mongodb.ObjectID(id)
            });
        });
    }
}<commit_msg>Added RoomDataService.createRoom<commit_after>import * as mongodb from 'mongodb';
import { BaseDataService } from './BaseDataService'

export class RoomDataService extends BaseDataService{
    public getRoomList(): Promise<any[]> {
        return this.connectToDB().then((db) => {
            let rooms = db.collection('rooms');
            return rooms.find({}).toArray();
        });
    }

    public getRoom(id: string) {
        return this.connectToDB().then((db) => {
            let rooms = db.collection('rooms');
            return rooms.findOne({
                _id: new mongodb.ObjectID(id)
            });
        });
    }

    /**
     * Creates the room on database
     * @param roomInfo Information on room
     * 
     * @returns The roomInfo with id
     */
    public createRoom(roomInfo): Promise<any> {
        return this.connectToDB().then((db) => {
            let rooms = db.collection('rooms');
            return rooms.insertOne(roomInfo).then((result) =>{
                roomInfo.id = result.insertedId.toHexString();
                return roomInfo;
            });
        })
    }
}
{'fraction_non_alphanumeric': 0.13529073114565343, 'fraction_numerical': 0.0, 'mean_word_length': 2.092526690391459, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7198085', 'n_tokens_mistral': 485, 'n_tokens_neox': 469, 'n_words': 104}