Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URL_ATLAS=mongodb+srv://mybrary:<password>@cluster0.wshfo.mongodb.net/mybrary?retryWrites=true&w=majority
DATABASE_URL_LOCAL=mongodb://127.0.0.1:27017/mybrary
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.env
node_modules
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
7 changes: 4 additions & 3 deletions models/book.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const mongoose = require('mongoose')

const coverImageBasePath='uploads/books'
const bookSchema = new mongoose.Schema({
title: {
type: String,
Expand Down Expand Up @@ -38,8 +38,9 @@ const bookSchema = new mongoose.Schema({

bookSchema.virtual('coverImagePath').get(function() {
if (this.coverImage != null && this.coverImageType != null) {
return `data:${this.coverImageType};charset=utf-8;base64,${this.coverImage.toString('base64')}`
return `data:${this.coverImageType};charset=utf-8;base64,${this.coverImage.toString("base64")}`
}
})

module.exports = mongoose.model('Book', bookSchema)
module.exports = mongoose.model('Book', bookSchema)
module.exports.coverImageBasePath = coverImageBasePath
Binary file added npm.ps
Binary file not shown.
Loading