rx3-to-mastodon/mongo.js
2019-12-25 18:36:55 +01:00

49 lines
1 KiB
JavaScript

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.set('debug', true)
mongoose.connect(config.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true })
const db = mongoose.connection
db.on('error', console.error.bind(console, 'connection error:'))
module.exports = {
Histories: Histories,
Metadata: Metadata
}