Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
169 lines (163 loc) · 5.61 KB

File metadata and controls

169 lines (163 loc) · 5.61 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Copyright 2014-2017 MarkLogic Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var should = require('should');
var fs = require('fs');
var stream = require('stream');
var util = require('util');
var concatStream = require('concat-stream');
var valcheck = require('core-util-is');
var testconfig = require('../etc/test-config.js');
var testutil = require('./test-util.js');
var marklogic = require('../');
var q = marklogic.queryBuilder;
var db = marklogic.createDatabaseClient(testconfig.restWriterConnection);
describe('quick path', function(){
before(function(done){
db.documents.write({
uri: '/test/quick/object1.json',
collections: '/quickdocs',
contentType: 'application/json',
content: {quickKey: 'quickMatch'}
},{
uri: '/test/quick/object2.json',
collections: '/quickdocs',
contentType: 'application/json',
content: {quickKey: 'quickMatch'}
})
.result(function(response){done();})
.catch(done);
});
it('should create objects', function(done){
db.createCollection(
'/quickdocs',
{quickKey: 'quick value 1'},
{quickKey: 'quick value 2'}
)
.result(function(uris){
valcheck.isUndefined(uris).should.equal(false);
uris.length.should.equal(2);
return db.documents.read({uris:uris, categories:['content', 'collections']}).result();
})
.then(function(documents) {
valcheck.isUndefined(documents).should.equal(false);
documents.length.should.equal(2);
documents[0].should.have.property('content');
documents[0].content.should.have.property('quickKey');
documents[0].should.have.property('collections');
documents[0].collections[0].should.equal('/quickdocs');
documents[1].should.have.property('content');
documents[1].content.should.have.property('quickKey');
documents[1].should.have.property('collections');
documents[1].collections[0].should.equal('/quickdocs');
done();
})
.catch(done);
});
it('should write a mapping', function(done){
db.writeCollection(
'/quickmapped',
{
'/quickmapped/doc1.json': {mappedKey: 'quick value 1'},
'/quickmapped/doc2.xml': '<quickDoc>quick content 2</quickDoc>'
}
)
.result(function(uris){
valcheck.isUndefined(uris).should.equal(false);
uris.length.should.equal(2);
return db.documents.read({uris:uris, categories:['content', 'collections']}).result();
})
.then(function(documents) {
valcheck.isUndefined(documents).should.equal(false);
documents.length.should.equal(2);
documents[0].should.have.property('content');
documents[0].content.should.have.property('mappedKey');
documents[0].should.have.property('collections');
documents[0].collections[0].should.equal('/quickmapped');
documents[1].should.have.property('content');
documents[1].content.should.containEql('<quickDoc>quick content 2</quickDoc>');
documents[1].should.have.property('collections');
documents[1].collections[0].should.equal('/quickmapped');
done();
})
.catch(done);
});
it('should read objects', function(done){
db.read('/test/quick/object1.json', '/test/quick/object2.json')
.result(function(objects) {
valcheck.isUndefined(objects).should.equal(false);
objects.length.should.equal(2);
objects[0].should.have.property('quickKey');
objects[0].quickKey.should.equal('quickMatch');
objects[1].should.have.property('quickKey');
objects[1].quickKey.should.equal('quickMatch');
done();
})
.catch(done);
});
it('should query objects', function(done){
db.queryCollection(
'/quickdocs',
q.where(q.byExample({
quickKey: 'quickMatch'
})))
.result(function(objects) {
valcheck.isUndefined(objects).should.equal(false);
objects.length.should.equal(2);
objects[0].should.have.property('quickKey');
objects[0].quickKey.should.equal('quickMatch');
objects[1].should.have.property('quickKey');
objects[1].quickKey.should.equal('quickMatch');
done();
})
.catch(done);
});
it('should remove a document', function(done) {
var docUri = '/test/quick/object1.json';
db.remove(docUri)
.result(function(response) {
response.should.be.an.Array;
response.length.should.equal(1);
return db.probe(docUri).result();
})
.then(function(exists) {
exists.should.eql(false);
done();
})
.catch(done);
});
it('should probe', function(done){
db.probe('/test/quick/object2.json')
.result(function(exists) {
exists.should.eql(true);
done();
})
.catch(done);
});
it('should remove a collection', function(done){
var collectionUri = '/quickdocs';
this.timeout(3000);
db.removeCollection(collectionUri)
.result(function(collection) {
collectionUri.should.eql(collection);
return db.probe('/test/quick/object2.json').result();
})
.then(function(exists) {
exists.should.eql(false);
done();
})
.catch(done);
});
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.