当我在FindArtist.js
文件中运行此代码时,我的 Electron 应用程序中出现错误:
const Artist = require('../models/artist');
/**
* Finds a single artist in the artist collection.
* @param {string} _id - The ID of the record to find.
* @return {promise} A promise that resolves with the Artist that matches the id
*/
module.exports = _id => {
return Artist.findOne({ _id: _id });
};
我确实安装了猫鼬,但似乎我不再适当地导入猫鼬或艺术家模型?没有把握。
这是models/artist.js
文件:
const mongoose = require('mongoose');
const AlbumSchema = require('./album');
const Schema = mongoose.Schema;
const ArtistSchema = new Schema({
name: String,
age: Number,
yearsActive: Number,
image: String,
genre: String,
website: String,
netWorth: Number,
labelName: String,
retired: Boolean,
albums: [AlbumSchema]
});
const Artist = mongoose.model('artist', ArtistSchema);
module.exports = ArtistSchema;