2019-12-01 17:56:13 +01:00
|
|
|
const mongoose = require('mongoose')
|
|
|
|
|
|
|
|
const config = require('./config')
|
|
|
|
|
|
|
|
const schemas = {
|
|
|
|
histories: mongoose.Schema({
|
|
|
|
artist: String,
|
|
|
|
title: String,
|
|
|
|
album: String,
|
|
|
|
royaltytrackid: Number,
|
2019-12-25 18:34:29 +01:00
|
|
|
id: Number,
|
|
|
|
stringId: String,
|
2019-12-01 17:56:13 +01:00
|
|
|
playlistId: Number,
|
|
|
|
thumbCover: String,
|
|
|
|
createdAt: {
|
|
|
|
type: Date,
|
|
|
|
default: Date.now
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
metadata: mongoose.Schema({
|
|
|
|
artist: String,
|
|
|
|
title: String,
|
|
|
|
album: String,
|
|
|
|
royaltytrackid: Number,
|
|
|
|
id: Number,
|
2019-12-25 18:40:20 +01:00
|
|
|
stringId: String,
|
2019-12-01 17:56:13 +01:00
|
|
|
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)
|
|
|
|
|
2019-12-25 18:36:55 +01:00
|
|
|
mongoose.set('debug', true)
|
|
|
|
|
|
|
|
mongoose.connect(config.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true })
|
2019-12-01 17:56:13 +01:00
|
|
|
|
|
|
|
const db = mongoose.connection
|
|
|
|
db.on('error', console.error.bind(console, 'connection error:'))
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Histories: Histories,
|
|
|
|
Metadata: Metadata
|
|
|
|
}
|