The MongoDB script is loading properly, however, it is not functioning as expected

As someone new to MongoDB, I've put together this JavaScript file:

db=connection.getDB("TPMongo1028257");
var inversiones=[{
            categoria:"Accion",
            fdc:new Date(2019,07,05,0,0),
            iin: NumberDecimal ("5214.365"),
            cantidad:5,
            precioac: NumberDecimal ("9005.3659"),
            asesor:{
                nombre:"Carlos Solange",
                sitM:"Suba de las acciones",
                recom:"Comprar mas acciones",
},
            operacion:[{
                cat:"Accion",
                fdo:new Date(2019,10,15,0,0),
                importe: NumberDecimal ("9055.3659"),
                tipo:"Compra",
                asesor: "Carlos Solange"
            },
            {
                cat:"Accion",
                fdo:new Date(2019,11,05,0,0),
                importe: NumberDecimal ("9189.1789"),
                tipo:"Compra",
                asesor:"Carlos Solange"
}],                  
},
// More data here...

Upon loading the file, everything seems to be in order as it returns "true" and displays my collection when queried with db.getCollectionNames(). However, when I try running db.[INSERT_DB_NAME].find(), no results are returned. This issue occurs on multiple computers running Ubuntu 18.04.

I apologize if this is a basic question, but I could really use some guidance right now.

Answer №1

I realized that I forgot to send the command to the recently established connection. What a silly mistake on my part.

Once I executed use TPMongo1028257, everything started functioning correctly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Harnessing the power of Promise to verify the completion of a filestream

After initializing the variables below, I update them while parsing through a large CSV file, which can be time-consuming. var yearTotal2008 = 0; var year2008TallyByPatient = {}; To process the CSV file, I use the following function: const produceChart ...

Objects remaining static

I'm currently working on a VueJS component that has the ability to export data into .xlsx format. To achieve this functionality, I am utilizing the json2xls library, which requires an array of objects with identical keys (representing column names) to ...

Looking to replicate a Modal that I designed, but unsure which elements need altering in order to achieve this. I am hoping to create three duplicates of the Modal

This modal is functioning perfectly, and now I want to replicate the same modal three times on a single page. I require three distinct buttons on the same page to trigger these separate modals. At this point, I am unsure which attributes need modification ...

Analyzing two sets of appointment schedules and resolving any overlapping conflicts

My goal is to dynamically generate available appointment times based on the number of employees working at a given time and the number of slots already filled. Let's say we have two employees working, one from 4:30 - 7:00 and the other from 4:30 - 7:3 ...

I'm curious about this specific expression in express.js - can you explain its significance?

Could you please provide a thorough explanation of the following line of code in NodeJS: var app = module.exports = express.createServer(); ...

Annoying underlines from JavaScript active links - no thanks!

Today I am facing a problem. I want to create a script that will emphasize the active link that I clicked on. I'm not sure how to do this. Can you provide me with some advice? I have an idea, but I'm not certain if it's the best solution. ...

Adding a dropdown feature in a React.js component

I am working on a React project that requires me to create a dropdown menu using only pure React. The dropdown should also be responsive for different devices. The expected interactions are as follows: For larger devices like desktop screens: On hover Fo ...

Is there a way to integrate the Twitter strategy of passport.js into a Restful API?

I am currently in the process of creating a basic RESTful API using Node.js and MongoDB. My intention is to implement the Twitter Strategy provided by Passport.js. Most of the resources I have found feature examples related to web applications where rout ...

Is there a way to consolidate records from multiple rows into a single row on BigQuery?

I successfully loaded values into BigQuery from a JSON file, but my JSON file contains multiple objects. For example: {"A": {"queryID": "newId", "newCol": "newCol"}} {"B": {"date": "2013-05-31 20:56:41", "device": "pc"}} {"C": {"keyword": ["new", "ict"]} ...

Slider - incorporating a heading onto a video with HTML styling

Is there a way to display a title on a slider when one of the slides contains a video? Here is an example code snippet: <!-- Swiper--> <div data-height="100vh" data-min-height="480px" data-slide-effect="fade" class="swiper-container swiper-s ...

SQL stores Array Input as a static identifier 'Array'

Previously, I was able to save an object in the database. However, now I need to save each individual data in an array within a row. I attempted to use array_column to store a specific set of data in a column, but it ended up saving as the word 'Array ...

Utilize Node.js and Java to fetch MQTT data in an asynchronous manner

I have been working on a project to create a publish/subscribe application where a Java program acts as the publisher and a NodeJS program as the subscriber. The Java client connects to an MQTT server and sends random data, while the NodeJS client subscrib ...

what sets apart parseint from minus

Typically, my approach for parsing numbers in JavaScript involves the following code snippet: var x = "99" var xNumber = x - 0 as opposed to using: var xNumber = parseInt(x) I am curious to know if there are any potential issues with this method in ter ...

The function purported by WEBPACK_MODULE_13___default(...) does not exist

Scenario : I've been working on a small library (let's call it myLibrary) using TypeScript and Webpack. Everything seemed to be running smoothly until I imported the library into a React application, which resulted in a crash. On the Library Sid ...

The Journey of React Components: How Child Components Embrace the State Props of the Past

My understanding of states and props in React seems to be off. I am working on a React, Redux based app. Situation: I have a global SVG component that grabs the viewport dimensions from the app in the componentDidMount method. The default props for the ...

What is the best method for eliminating xmlPayload when sending a JSON Array using WSO2 API Manager?

We have successfully implemented WSO2 API Manager 1.6 and are now configuring a RESTful webservice to work with it. However, we are experiencing an issue where a JSON array sent to the webservice gets altered. Our configuration involves using axis2.xml_PT ...

Tips on implementing Piwik JavaScript code within app.js on Express

I am trying to implement Piwik tracking on my Express website using JavaScript code. I placed the code in my app.js file but encountered an error. Here is the JavaScript code snippet: <script type="text/javascript"> var _paq = _paq || []; ...

Encountering a bizarre npm issue while attempting to execute npm install for brain.js

Encountering a puzzling error while attempting to install brain.js. Unsure of why Python is being mentioned during the installation process via npm, as there are no similar situations found on Google (and I'm not quite sure how to search for it). G:& ...

Generating a JSON data set with two separate pieces of data, not contained within a dictionary

Within my application, there exists an HTML table that is dynamically generated using the following code: function generateTableRow() { var emptyColumn = document.createElement('tr'); emptyColumn.className ='data'; emptyColumn.inne ...

Using MongoDB: Applying $match to a subdocument following $lookup操作

How can I retrieve timecards linked to jobs that are in turn linked to facilities with a specific facility ID through an aggregation query? Timecard.aggregate([ { $match: query }, //some query parameters set before, doesn't matter here { ...