We help IT Professionals succeed at work.

Why Doesn't This Collection Automatically Show Up in my MongoDB?

High Priority
136 Views
Last Modified: 2019-09-25
Here's a portion of my app.js file:

const express = require("express");
const jwt = require("jsonwebtoken"); //this is the package that decrypts your token
const mongoose = require("mongoose");
//const compression = require("compression");

const app = express();
const superPassword = process.env.SIGNATURE; //here's where you're grabbing your SIGNATURE constant from your .env file that's in your root directory
const conn = process.env.CONNECTION;

const Auth = require("./models/auth");

Open in new window


Here's my "auth.js" model:

const mongoose = require("mongoose");

const Schema = mongoose.Schema;

const authSchema = new Schema({
  app: {
    type: String,
    required: true
  },
  token: {
    type: String,
    required: true
  }
});

module.exports = mongoose.model("Auth", authSchema);

Open in new window


I'm expecting to see a new "auth" collection in my MongoDB but I'm not seeing it.

Am I missing something?
Comment
Watch Question

Software Engineer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Javascript is not a language i use often... (and it was long ago..)
I see only declarations, no active running code .  
Again i might miss something.., isn't there supposed to be something / activated?
Bruce GustPHP Developer

Author

Commented:
noci, you were more on point than you know. I inserted a row using the model that I instantiated at the top of the script and once the table was actually engaged, it kicked into gear!
Bruce GustPHP Developer

Author

Commented:
BOOM!
nociSoftware Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
no problem. thanx.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.