Encountered an ERROR with MONGO_OBJECT_REMOVED while attempting to Add Data to Mongo Collection

While attempting to insert data into MongoDB, the console.log output for rcitems showed an error message indicating "MONGO_OBJECT_REMOVED".

I am currently utilizing Meteor, Blaze, Simple-Schema, and Collection2.

The expected outcome for rcitems is to display an array of product, quantity, lot, and expiration date Objects.

Upon removing the INSERT to Mongo Code, the rcitems displayed the data correctly.

Please refer to the following image for details: ERROR Image

The image shows correct functionality after removing the Receive.insert(...) code: Working Image

Template.receiveForm.events({
  'submit form': function(event, template){
    event.preventDefault();
    var rcitems = [];
    let docdate = event.target.docdate.value;
    docdate = moment(docdate, "DD-MM-YYYY").toISOString();
    let supplier = event.target.supplier_sel.value;
    var trs = $('tbody tr');

    //Build receiveLot Array
    trs.each(function(tr){
      let prodid = $(this).closest('tr').attr('id');
      let prodname = $(this).find(".prodname").html();
      let quantity = Number($(this).find("#quantity").val());
      let lot = $(this).find("#lotno").val() || 0;
      let expdate = $(this).find("#expdate").val() || 0;
      console.log(prodid);
      console.log(prodname);
      console.log(quantity)
      console.log(lot)
    });
    console.log(rcitems);
    var recvdoc = {'docdate' : docdate, 'supplier': supplier, 'receiveItems': rcitems};
    console.log(recvdoc);
    //Insert to Receive Collection
    Receive.insert(recvdoc, function( error, result ){
      if (error) {
        console.log(error);
      } else {
        console.log("Insert Success");
        console.log(result);
      }
    });
  }
});

SCHEMA

import SimpleSchema  from 'simpl-schema';

Receive = new Mongo.Collection("receive");
Receive.attachSchema(new SimpleSchema({
  docdate: {
    type: Date,
    label: "Document Date",
  },
  supplier: {
    type: String,
    label: "Supplier",
  },
  receiveItems:{
    type: Array,
    blackbox: true,
    label: "Receive Lot",
  },
}));

Answer №1

The solution has been successfully identified.

blackbox is not compatible with the Array type, so I made a modification from

  receiveItems:{
    type: Array,
    blackbox: true,
    label: "Receive Lot",
  },

to

  receiveItems:{
    type: Array,
    label: "Receive Lot",
  },
  'receiveItems.$':{
    type: Object,
    blackbox: true,
  },

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

Issues with jKit Pagination (Controlling Size by Height)

I'm currently utilizing the jkit paginate feature to limit the number of items by height, with the setting at 910 pixels. Everything works fine when there is enough content to exceed this limit and create a second page. However, if the content falls ...

"Could you please refresh the mongoDB database with the latest todolist details

I have integrated a todolist feature into my frontend. You can check out a demo of it here: https://gyazo.com/a10fcd7c470439fe5cc703eef75b437f The functionality is driven by an array in a Vue component, utilizing v-models to manage the data and update the ...

Tips for navigating through the search results on Google Maps with Selenium

I am facing an issue where I am only able to retrieve the first 7 results out of 20 using the given code. It seems that I am unable to scroll to the bottom to access all the results. Can someone please advise on additional steps required to achieve the d ...

What is the process for choosing every child (regardless of level) of a parent using jQuery?

Is there a way to unbind all elements from a parent node using jQuery? How can I effectively select all children, regardless of their nesting level, from a parent node? I attempted the following: $('#google_translate_element *').unbind('c ...

Is there a more effective approach to managing an array of objects retrieved from an API call?

I'm attempting to extract an array of names from a JSON response that contains an array of objects, but I'm running into issues. When I try to print the array, it shows up empty. Is this the correct way to go about it? There don't seem to be ...

Global installation of Meteor packages

Is there a method to globally install meteor packages? By having the ability to install packages globally and access them without requiring an internet connection in future projects, it can save time from repetitive downloads and offer other advantages. ...

Exploring the functionalities of class methods within an Angular export function

Is it possible to utilize a method from an exported function defined in a class file? export function MSALInstanceFactory(): IPublicClientApplication { return new PublicClientApplication({ auth: AzureService.getConfiguration(), <-------- Com ...

JavaScript Node.js Error: Attempting to Read 'get' Property of Undefined

Struggling with an external GET request to an endpoint for general information? I've explored various Node methods and crafted the request below (with a few details altered). However, I encounter an issue when I run the https.get command. Despite suc ...

Utilize Google Maps to receive directions to a specific destination and discover current traffic conditions along the route using their comprehensive API

I am currently working on implementing the Google Maps direction identifier functionality with traffic details. However, I am able to obtain directions but not specific traffic details for a selected path; it seems to apply overall traffic data instead. ...

Refreshing a sibling component because of data changes in another sibling component within Next JS

I have a Next JS application where I am utilizing the Layout feature within the _app.tsx component. The layout includes a sidebar that is populated from an API call using a GET request. In addition, there is another API call (update request) triggered on ...

Alert event in JavaScript navigating between different pages

My website features two dynamic php pages: customer invoices and customer management. One common request from my users is the ability to swiftly add a new customer directly from the customer invoices page. Instead of cluttering the customer invoices page ...

Troubleshooting: HighCharts xAxis not displaying dates correctly when using JSON data

/* Analyzing Historical Performance */ document.addEventListener('DOMContentLoaded', function() { const lineChartUrl = 'https://bfc-dashboard-api.herokuapp.com/line_chart'; Highcharts.getJSON(lineChartUrl, function(data) { va ...

"Using jQuery to prevent propagation from interfering with an ajax GET request

I'm facing an issue with a table that has clickable rows and ajax links in the rightmost column. Whenever I click on the link within a row, the row's click event is triggered as well. To prevent the event propagation, I tried using stopPropagati ...

The decoding of my JSON data in PHP is not working as expected

My AJAX is sending JSON data to my PHP script, but I'm encountering an issue with decoding it. This is the jQuery code: $.ajax({ url : 'admin/modifyPermissions', type : 'post', data : { 'JSON' : JSON ...

What steps can I take to ensure that this input is neat and tidy

I need to implement conditional styling for my input field. The current layout is chaotic and I want to improve it. Specifically, when the active item is "Height", I only want to display the height value and be able to change it using setHeight. const [a ...

Experiencing excessive memory usage when attempting to load a large JSON file in Firefox

We are in the process of developing a client-based application using HTML5 and indexedDB on Firefox 28. When large amounts of data are loaded to Firefox for the first time using AJAX requests in JSON format, each JSON response is approximately 2MB (gzipped ...

Is it possible to pass a constant to another constant within Angular?

Is there a way to define a constant in Angular that depends on another constant being passed to it? See this example: angular .constant("names", ["Bob", "Jane"]) .constant("friends", ["names", getFriends]); function getFriends(names) { var friends ...

Explore the possibilities of using a unique custom theme with next.js, less, and ant design

Trying to customize the default theme in antdesign has been a challenge for me. I've switched from sass to less, but there seems to be something that just won't work. I've exhaustively searched online for solutions - from official nextjs ex ...

Transforming a JSON object into a list in C#

After exploring similar posts without success, I am reaching out here for help. I have a Json data stored in a hidden field that I am trying to access in the code behind file of my markup page. My goal is to convert this Json into a List and bind it to a ...

What is the reason why sinon stub is unable to replace the actual exports.function?

I have a situation where my controller async function is calling another async exported function. I am looking to test specific results of the dependent function rather than testing the dependency itself. However, when I try to stub the function, it seems ...