fix: renamed logs
sub-collection to log
as per fcc test requirements
This commit is contained in:
parent
cfa55c020f
commit
33356d1fa5
8
index.js
8
index.js
@ -15,7 +15,7 @@ mongoose.connect(MONGODB_URI, {
|
|||||||
|
|
||||||
const exerciseLogsSchema = new mongoose.Schema({
|
const exerciseLogsSchema = new mongoose.Schema({
|
||||||
username: { type: String, required: true },
|
username: { type: String, required: true },
|
||||||
logs: [
|
log: [
|
||||||
{
|
{
|
||||||
description: { type: String, required: true },
|
description: { type: String, required: true },
|
||||||
duration: { type: Number, required: true },
|
duration: { type: Number, required: true },
|
||||||
@ -92,7 +92,7 @@ app.post("/api/users/:_id/exercises", (req, res) => {
|
|||||||
{ _id: _id },
|
{ _id: _id },
|
||||||
{
|
{
|
||||||
$push: {
|
$push: {
|
||||||
logs: {
|
log: {
|
||||||
description: description,
|
description: description,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
date: date,
|
date: date,
|
||||||
@ -141,8 +141,8 @@ app.get("/api/users/:_id/logs", (req, res) => {
|
|||||||
.then((excLogs) => {
|
.then((excLogs) => {
|
||||||
if (excLogs) {
|
if (excLogs) {
|
||||||
let excLogsJson = excLogs.toJSON();
|
let excLogsJson = excLogs.toJSON();
|
||||||
excLogsJson.count = excLogsJson.logs.length;
|
excLogsJson.count = excLogsJson.log.length;
|
||||||
excLogsJson.logs = excLogsJson.logs.map((log) => {
|
excLogsJson.log = excLogsJson.log.map((log) => {
|
||||||
log.date = new Date(log.date).toDateString();
|
log.date = new Date(log.date).toDateString();
|
||||||
return log;
|
return log;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user