Mongo only inserts first object inside promise, how to see error?

hi,

I have a method, and this uses a promise to get external data (this works perfectly).

  • The first database insert works fine (for testing purposes)
  • but if I do it inside the loop of my promise he only inserts the first. And I suspect an error but how can I see the error?
  • if I remove the mondoDB Apps.insert statement it prints the name of all my objects… so it goes wrong here

thank you!

updateAppsCollection(){
    		console.log('Method: update the local mongoDB with fresh data from Qlik Sense');
    		Apps.remove();
    		**Apps.insert({**
    **			"id": "05ebb949-ab3d-496a-a5d9-779115bb1c0a",**
    **			"name": "test1",**
    **		});**

    		var myPromise = qrs.get( '/qrs/app/full')  //this REST api function returns a promise
    		.catch(err => {
    			throw new Meteor.Error(err)
    		})
    		myPromise.then(function(docList){
    			docList.forEach(function(doc) {
    				**console.log('inserted ', doc);**
**    				Apps.insert(doc);**
    			})
    		}).catch(err => {
    			throw new Meteor.Error(err)
    		})
    	}

In the console try this:

meteor mongo
db.apps.drop() //maybe it is a problem of IDs

then try to change your code like this:

myPromise.then(function(docList){
Apps.insert(docList);
}).catch(err => {

You have a list of documents, you can insert it all in one instruction COLLECTION.insert([ARRAY OF DOCUMENTS]);

Thank you. It is so strange…

  • When I console.log the doclist it shows all items.
  • But when I try to insert it into the database nothing happens. (some error which I can’t see apparently)

This is now my code

updateAppsCollection(){
		console.log('Method: update the local mongoDB with fresh data from Qlik Sense');
		
		try{
			Apps.remove();
		}
		catch(error){console.log(err)};

		var myPromise = qrs.get( '/qrs/app/full');
		
		myPromise.then(
			function(docList){					
				try{
					console.log('try to insert document array into mongo');					
					Apps.insert(docList);		
					console.log('inserted document ', docList);				
				}
				catch(error){console.log(err)}

			}, function (error) {
   				 console.error('uh oh: ', error);   // 'uh oh: something bad happened’
   				});

		myPromise.catch(function(error) {
			console.log('Caught!', error);
		});

	}

Console output
=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

I20160523-11:24:34.400(2)? Meteor server has started. Calling updateAppsCollection
I20160523-11:24:34.400(2)? Method: update the local mongoDB with fresh data from Qlik Sense
I20160523-11:24:35.128(2)? try to insert document array into mongo

you can try this:

try{
	console.log('try to insert document array into mongo');
	Apps.insert(docList, 
                   function(err,res){
                        console.log("insert error: ",err); 
                        console.log("insert result: ",res);
                   }
        );
    console.log('inserted document ', docList);	
}

if the problem remains please log the docList in the console before Apps.insert

Thank you, the output remains the same… Looks like the callback is never called? that would also explain why I never get an error!

Meteor server has started. Calling updateAppsCollection
Method: update the local mongoDB with fresh data from Qlik Sense
try to insert document array into mongo

If I try to log the doclist i get, (the doclist contains 140 documents each has 14 lines of code)

FATAL ERROR: Evacuation Allocation failed - process out of memory

Please note that it also not works if I just do app.insert({name: ‘test’})

 [
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "c487d19c-66c5-49c8-a14c-f56a025347ef",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:54:59.035Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/c487d19c-66c5-49c8-a14c-f56a025347ef/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "c487d19c-66c5-49c8-a14c-f56a025347ef",
				"$$hashKey": "02R"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "a50e1f01-cb7c-400a-8109-b6da8abf9aa8",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:00.620Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/a50e1f01-cb7c-400a-8109-b6da8abf9aa8/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "a50e1f01-cb7c-400a-8109-b6da8abf9aa8",
				"$$hashKey": "02S"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "63344598-3ed7-47ff-a8a9-133415a5c725",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:01.946Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/63344598-3ed7-47ff-a8a9-133415a5c725/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "63344598-3ed7-47ff-a8a9-133415a5c725",
				"$$hashKey": "035"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "cfb172eb-b910-4322-88f2-298e28c295ff",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:05.105Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/cfb172eb-b910-4322-88f2-298e28c295ff/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "cfb172eb-b910-4322-88f2-298e28c295ff",
				"$$hashKey": "02T"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "ce8f7d51-3122-40f9-a942-9b31db628fb8",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:54:58.537Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/ce8f7d51-3122-40f9-a942-9b31db628fb8/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "ce8f7d51-3122-40f9-a942-9b31db628fb8",
				"$$hashKey": "02U"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "ddfb77f8-1271-4ca6-a191-52172fafff67",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:02.937Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/ddfb77f8-1271-4ca6-a191-52172fafff67/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "ddfb77f8-1271-4ca6-a191-52172fafff67",
				"$$hashKey": "02V"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "b5c72d05-778c-4b30-9900-42262c1c994a",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:54:56.863Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/b5c72d05-778c-4b30-9900-42262c1c994a/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "b5c72d05-778c-4b30-9900-42262c1c994a",
				"$$hashKey": "02W"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "a5e1ddc8-c08d-4962-884a-273e4d3f61f8",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:51:46.045Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/a5e1ddc8-c08d-4962-884a-273e4d3f61f8/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "a5e1ddc8-c08d-4962-884a-273e4d3f61f8",
				"$$hashKey": "02X"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "082c379d-f0aa-4259-9bcd-43bf22e6151f",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:51:46.906Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/082c379d-f0aa-4259-9bcd-43bf22e6151f/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "082c379d-f0aa-4259-9bcd-43bf22e6151f",
				"$$hashKey": "02Y"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "6600a938-66d1-428c-b10f-383a4e17f052",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:51:43.415Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/6600a938-66d1-428c-b10f-383a4e17f052/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "6600a938-66d1-428c-b10f-383a4e17f052",
				"$$hashKey": "02Z"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "1ae61499-9ea7-4b75-93e7-0165bc3e91d6",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:51:47.666Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/1ae61499-9ea7-4b75-93e7-0165bc3e91d6/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "1ae61499-9ea7-4b75-93e7-0165bc3e91d6",
				"$$hashKey": "030"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "4a544099-ffff-4004-8170-3eb1b3fb5ff1",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:54:56.506Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/4a544099-ffff-4004-8170-3eb1b3fb5ff1/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "4a544099-ffff-4004-8170-3eb1b3fb5ff1",
				"$$hashKey": "031"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "0dd9f2ae-ea02-4bde-b592-1f28516b7259",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:05.459Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/0dd9f2ae-ea02-4bde-b592-1f28516b7259/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "0dd9f2ae-ea02-4bde-b592-1f28516b7259",
				"$$hashKey": "032"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "6951a182-9bdf-4353-a306-1f1f800e46ed",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:51:47.964Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/6951a182-9bdf-4353-a306-1f1f800e46ed/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "6951a182-9bdf-4353-a306-1f1f800e46ed",
				"$$hashKey": "033"
			},
			{
				"qDocName": "[object Object]Sales replace name",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "957c53da-5280-45da-8979-16a0b224b54e",
				"qMeta": {
					"modifiedDate": "2016-05-21T21:55:04.705Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "[object Object]Sales replace name",
				"qThumbnail": {
					"qUrl": "/appcontent/957c53da-5280-45da-8979-16a0b224b54e/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "957c53da-5280-45da-8979-16a0b224b54e",
				"$$hashKey": "034"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "2a867ce2-20b1-4120-ab01-ef4b62ecf3be",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:05:17.878Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/2a867ce2-20b1-4120-ab01-ef4b62ecf3be/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "2a867ce2-20b1-4120-ab01-ef4b62ecf3be",
				"$$hashKey": "03Q"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "f77683b7-cd9c-4f1a-b643-71162da1921a",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:06:31.206Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/f77683b7-cd9c-4f1a-b643-71162da1921a/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "f77683b7-cd9c-4f1a-b643-71162da1921a",
				"$$hashKey": "036"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "ceac7b73-72d5-4ed4-a287-35fa4791be4b",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:06:34.150Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/ceac7b73-72d5-4ed4-a287-35fa4791be4b/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "ceac7b73-72d5-4ed4-a287-35fa4791be4b",
				"$$hashKey": "03V"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "52c4718b-e1bc-44aa-962a-639eaa84c5d2",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:05:15.605Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/52c4718b-e1bc-44aa-962a-639eaa84c5d2/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "52c4718b-e1bc-44aa-962a-639eaa84c5d2",
				"$$hashKey": "038"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "ae9bbb8f-b40a-4ff9-a1af-0fb167133119",
				"qMeta": {
					"modifiedDate": "2016-05-18T18:55:21.839Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/ae9bbb8f-b40a-4ff9-a1af-0fb167133119/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "ae9bbb8f-b40a-4ff9-a1af-0fb167133119",
				"$$hashKey": "039"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "c846644f-a848-4724-829b-8c0de39b0f9a",
				"qMeta": {
					"modifiedDate": "2016-05-19T10:59:37.897Z",
					"published": true,
					"publishTime": "2016-05-19T10:59:29.546Z",
					"privileges": [
						"read"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": {
						"id": "aaec8d41-5201-43ab-809f-3063750dfafd",
						"name": "Everyone"
					},
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/c846644f-a848-4724-829b-8c0de39b0f9a/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "c846644f-a848-4724-829b-8c0de39b0f9a",
				"$$hashKey": "03A"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "08158185-a987-478b-b07e-65035d319198",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:11:48.073Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/08158185-a987-478b-b07e-65035d319198/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "08158185-a987-478b-b07e-65035d319198",
				"$$hashKey": "03B"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "94ba9b5b-c269-4a42-b293-24965a7d206e",
				"qMeta": {
					"modifiedDate": "2016-05-19T06:55:20.923Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/94ba9b5b-c269-4a42-b293-24965a7d206e/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "94ba9b5b-c269-4a42-b293-24965a7d206e",
				"$$hashKey": "03C"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "3915afad-28ce-4585-9ba7-40b8ec330c74",
				"qMeta": {
					"modifiedDate": "2016-05-18T18:55:19.343Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/3915afad-28ce-4585-9ba7-40b8ec330c74/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "3915afad-28ce-4585-9ba7-40b8ec330c74",
				"$$hashKey": "03D"
			},
			{
				"qDocName": "biessales",
				"qConnectedUsers": 0,
				"qFileTime": 0,
				"qFileSize": 0,
				"qDocId": "f7a05e8d-d760-4ab1-bed7-da3af6ace9ff",
				"qMeta": {
					"modifiedDate": "2016-05-18T19:11:44.188Z",
					"published": false,
					"publishTime": "1753-01-01T00:00:00.000Z",
					"privileges": [
						"read",
						"update",
						"delete"
					],
					"description": "The Operations Monitor 2.2.0 provides information about the Qlik Sense server environment, including: server memory and CPU usage, active users, task reloads, and errors and warnings.",
					"qFileSize": 22034466,
					"dynamicColor": "",
					"create": null,
					"stream": null,
					"canCreateDataConnections": false
				},
				"qLastReloadTime": "2016-05-09T13:13:54.302Z",
				"qTitle": "biessales",
				"qThumbnail": {
					"qUrl": "/appcontent/f7a05e8d-d760-4ab1-bed7-da3af6ace9ff/Qlik_Images/Operations_Monitor_Thumbnail.png"
				},
				"key": "f7a05e8d-d760-4ab1-bed7-da3af6ace9ff",
				"$$hashKey": "03E"
			}
			
		]
	}

Are you expecting an insert on an array of n documents to insert n distinct documents into the collection?

It will insert one document. For example:

const names = [
  { name: 'Bob' },
  { name: 'Carol' },
  { name: 'Ted' },
  { name: 'Alice' },
];
Names.insert(names);

$ meteor mongo
meteor:PRIMARY> db.names.find()
{ "_id" : "qBoe45WTv9zyQospk", "0" : { "name" : "Bob" }, "1" : { "name" : "Carol" }, "2" : { "name" : "Ted" }, "3" : { "name" : "Alice" } }

If you need to insert separate documents, you will have to iterate over the list:

names.forEach(doc => {
  Names.insert(doc);
});

$ meteor mongo
meteor:PRIMARY> db.names.find()
{ "_id" : "ZFX7bRtFQsKc8wgXN", "name" : "Bob" }
{ "_id" : "vGQJozwovzjMHMYJt", "name" : "Carol" }
{ "_id" : "6g8vJSW3u9vjrWKho", "name" : "Ted" }
{ "_id" : "bzxWtR5EtToH8Pbdp", "name" : "Alice" }

I think that you have too many data to insert in the DB, please try this (just to test):

try{
	console.log('try to insert document array into mongo');
    var arr=[ docList[0], docList[1], docList[2] ];
	Apps.insert(arr, 
                   function(err,res){
                        console.log("insert error: ",err); 
                        console.log("insert result: ",res);
                   }
        );
    console.log('inserted document ', arr);	
}

if this works, you can try to follow this: Inserting 50000 documents into a collection

Thank you. Tried that as well. the issue here is basically. In my promise, meteor will not insert anything. even not

Apps.insert({name: ‘test’})

I suspect the callback never returns

I think it is a bug in meteor

  • the error logging was very strange, I noticed different behaviours also when restarting the server
  • If I try the same code on the client it works perfectly… (I still have autopublish on)

This code works client side:

Meteor.call('getApps', function(error, docList){
   if(error){
    console.error(error);
  }
  else{
    console.log('try to insert document array into mongo', docList);
    Apps.remove();
    docList.forEach(function(doc) {
     console.log('insered '+doc.qDocName);
     Apps.insert(doc, 
       function(err,res){
         console.log("insert error: ",err); 
         console.log("insert result: ",res);
       });
   })
  }

});

Get apps on the server

Meteor.methods({  
	generateStreamAndApp (customers, templateAppGuid) {
		check(customers, Array);
		check(templateAppGuid, String);
		return generateStreamAndApp(customers, templateAppGuid);
	},
	getApps () {
		return new Promise((resolve, reject) => {
			qsocks.Connect(engineConfig)
			.then(function(global) {
				global.getDocList().then(function(docList) {
					resolve(docList) ;
				});
			})
		})
		.catch(err => {
			throw new Meteor.Error(err)
		})
	},

So will this bug be solved somehow?

Do you have a repo I can install?

Hi, i can try to zip my project and send you an url?

Verstuurd vanaf mijn iPhone