const mongoose = require('mongoose') const config = require('./config') const schemas = { histories: mongoose.Schema({ artist: String, title: String, album: String, royaltytrackid: Number, id: Number, stringId: String, playlistId: Number, thumbCover: String, createdAt: { type: Date, default: Date.now } }), metadata: mongoose.Schema({ artist: String, title: String, album: String, royaltytrackid: Number, id: Number, playlistId: Number, thumbCover: String, cover: String, createdAt: { type: Date, default: Date.now } }) } const Histories = mongoose.model('histories', schemas.histories) const Metadata = mongoose.model('metadata', schemas.metadata) mongoose.connect(config.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true, debug: true }) const db = mongoose.connection db.on('error', console.error.bind(console, 'connection error:')) module.exports = { Histories: Histories, Metadata: Metadata }