Skip to content

documents query with stream not printing any contents. #419

Closed
@MukulAmbulgekar

Description

@MukulAmbulgekar

I am trying to upgrade Node Client API from 1.0.6 to 2.0.3. Below sample query does not print any document content and directly goes to the end event. I am running this query against 9.0-2 ML server.

Few observations -

  1. If I downgrade node client api to 1.0.6 , below query works perfectly
  2. If I pass chunked parameter to stream function - stream("chunked") it prints chunks.
  3. If I use result promise, it returns the expected document.

Sample Query

var marklogic = require('marklogic');
var connection = {
	host: 'localhost',
	port: 8000,
	user: 'admin',
	password: 'admin'
};
var db = marklogic.createDatabaseClient(connection);
var q = marklogic.queryBuilder;

db.documents.write({
	uri: '/users/markspace.json',
	collections: ['users'],
	contentType: 'application/json',
	content: {
		"username": "markspace",
		"email": "[email protected]",
		"name": "Mark Space",
		"createdAt": "2015-07-29T12:56:52.165662-07:00",
		"updatedAt": "2015-07-29T12:56:52.165662-07:00",
		"savedQueries": {
			"default": {
				"description": "This is the default query",
				"query": {
					"kind": "All",
					"assignTo": "markspace",
					"pageLength": "100",
					"page": 1
				}
			}
		},
		"alerts": {
			"alert-1": {
				"event": "created",
				"active": true,
				"query": {
					"kind": "Bugs",
					"status": [
						"New",
						"Verify",
						"Test"
					]
				}
			}
		},
		"active": true,
		"roles": [
			"user"
		],
		"githubUsername": ""
	}
})

db.documents.query(
		q.where(
			q.collection('users'),
			q.value('event', 'created')
		)
		.slice(0, 5)
	)
	/*.result(function(result){
	    console.log("result",JSON.stringify(result,null,2))
	})*/
	.stream().on('data', function(document) {
		console.log("data", document)
	})
	.on('end', function() {
		console.log("end")
	})
	.on('error', function(error) {
		console.log("error", JSON.stringify(error, null, 2))
	})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions