@@ -46,6 +46,111 @@ var patchBuilder = require('./patch-builder.js');
4646 * @borrows documents#write as DatabaseClient#write
4747 */
4848
49+ /**
50+ * Creates a database client to make database requests such as writes, reads,
51+ * and queries. The constructor takes a configuration object with the following
52+ * named parameters.
53+ * @function module:marklogic.createDatabaseClient
54+ * @param {string } [host=localhost] - the host with the REST server for the database
55+ * @param {number } [port=8000] - the port with the REST server for the database
56+ * @param {string } user - the user with permission to access the database
57+ * @param {string } password - the password for the user with permission to access
58+ * the database
59+ * @param {enum } [authType=digest] - the authentication type of digest or basic
60+ * @param {boolean } [ssl=false] - whether the REST server uses SSL; when true,
61+ * the connection parameters can include the
62+ * {@link http://nodejs.org/api/https.html#https_https_request_options_callback|supplemental
63+ * HTTPS options} specifiable for the node.js tls.connect() function.
64+ * @param {object } [agent] - defaults to a connection pooling agent
65+ * @returns {DatabaseClient } a client for accessing the database
66+ * as the user
67+ */
68+ function MarkLogicClient ( connectionParams ) {
69+ mlrest . initClient ( this , connectionParams ) ;
70+
71+ /**
72+ * Provides functions that write, read, query, or perform other operations
73+ * on documents in the database. As a convenience, the same functions are
74+ * provided on the database client.
75+ * @name documents
76+ * @memberof ! DatabaseClient#
77+ * @type {documents }
78+ */
79+ this . documents = new documents ( this ) ;
80+ /**
81+ * Provides functions that open, commit, or rollback multi-statement
82+ * transactions.
83+ * @name transactions
84+ * @memberof ! DatabaseClient#
85+ * @type {transactions }
86+ */
87+ this . transactions = new transactions ( this ) ;
88+
89+ /**
90+ * Provides access to namespaces that configure the REST server for the client.
91+ * The client must have been created for a user with the rest-admin role.
92+ * @name config
93+ * @memberof ! DatabaseClient#
94+ * @property {config.extlibs } extlibs - provides functions that
95+ * maintain the extension libraries on the REST server
96+ * @property {config.serverprops } serverprops - provides functions that
97+ * modify the properties of the REST server
98+ * @property {config.transforms } transforms - provides functions that
99+ * maintain the transform extensions on the REST server
100+ */
101+ this . config = {
102+ extlibs : new extlibs ( this ) ,
103+ serverprops : new restServerProperties ( this ) ,
104+ transforms : new transforms ( this )
105+ } ;
106+
107+ // to inspect
108+ // setClientLogger.call(this, {level:'debug'});
109+ }
110+
111+ // operation shortcuts
112+ function createReadStreamClient ( ) {
113+ return this . documents . createReadStream . apply ( this . documents , arguments ) ;
114+ }
115+ MarkLogicClient . prototype . createReadStream = createReadStreamClient ;
116+ function createWriteStreamClient ( ) {
117+ return this . documents . createWriteStream . apply ( this . documents , arguments ) ;
118+ }
119+ MarkLogicClient . prototype . createWriteStream = createWriteStreamClient ;
120+ function patchClient ( ) {
121+ return this . documents . patch . apply ( this . documents , arguments ) ;
122+ }
123+ MarkLogicClient . prototype . patch = patchClient ;
124+ function probeClient ( ) {
125+ return this . documents . probe . apply ( this . documents , arguments ) ;
126+ }
127+ MarkLogicClient . prototype . probe = probeClient ;
128+ function queryClient ( ) {
129+ return this . documents . query . apply ( this . documents , arguments ) ;
130+ }
131+ MarkLogicClient . prototype . query = queryClient ;
132+ function readClient ( ) {
133+ return this . documents . read . apply ( this . documents , arguments ) ;
134+ }
135+ MarkLogicClient . prototype . read = readClient ;
136+ function removeClient ( ) {
137+ return this . documents . remove . apply ( this . documents , arguments ) ;
138+ }
139+ MarkLogicClient . prototype . remove = removeClient ;
140+ function removeAllClient ( ) {
141+ return this . documents . removeAll . apply ( this . documents , arguments ) ;
142+ }
143+ MarkLogicClient . prototype . removeAll = removeAllClient ;
144+ function writeClient ( ) {
145+ return this . documents . write . apply ( this . documents , arguments ) ;
146+ }
147+ MarkLogicClient . prototype . write = writeClient ;
148+
149+ function releaseMarkLogicClient ( ) {
150+ mlrest . releaseClient . apply ( this , arguments ) ;
151+ }
152+ MarkLogicClient . prototype . release = releaseMarkLogicClient ;
153+
49154/**
50155 * Specifies logging for database interactions; takes a configuration
51156 * object with the following named parameters.
@@ -97,6 +202,8 @@ function setClientLogger(params) {
97202 mlrest . setLoggerLevel ( logger , level ) ;
98203 }
99204}
205+ MarkLogicClient . prototype . setLogger = setClientLogger ;
206+
100207/** @ignore */
101208function getClientLogger ( ) {
102209 var logger = this . logger ;
@@ -108,6 +215,8 @@ function getClientLogger() {
108215
109216 return logger ;
110217}
218+ MarkLogicClient . prototype . getLogger = getClientLogger ;
219+
111220/** @ignore */
112221function createConsoleTransport ( use ) {
113222 var console = new winston . transports . Console ( { timestamp : true } ) ;
@@ -129,83 +238,6 @@ function configClientLogger(client, transports) {
129238 return logger ;
130239}
131240
132- /**
133- * Creates a database client to make database requests such as writes, reads,
134- * and queries. The constructor takes a configuration object with the following
135- * named parameters.
136- * @function module:marklogic.createDatabaseClient
137- * @param {string } [host=localhost] - the host with the REST server for the database
138- * @param {number } [port=8000] - the port with the REST server for the database
139- * @param {string } user - the user with permission to access the database
140- * @param {string } password - the password for the user with permission to access
141- * the database
142- * @param {enum } [authType=digest] - the authentication type of digest or basic
143- * @param {boolean } [ssl=false] - whether the REST server uses SSL; when true,
144- * the connection parameters can include the
145- * {@link http://nodejs.org/api/https.html#https_https_request_options_callback|supplemental
146- * HTTPS options} specifiable for the node.js tls.connect() function.
147- * @param {object } [agent] - defaults to a connection pooling agent
148- * @returns {DatabaseClient } a client for accessing the database
149- * as the user
150- */
151- function MarkLogicClient ( connectionParams ) {
152- mlrest . initClient ( this , connectionParams ) ;
153-
154- this . release = mlrest . releaseClient . bind ( this ) ;
155-
156- /**
157- * Provides functions that write, read, query, or perform other operations
158- * on documents in the database. As a convenience, the same functions are
159- * provided on the database client.
160- * @name documents
161- * @memberof ! DatabaseClient#
162- * @type {documents }
163- */
164- this . documents = new documents ( this ) ;
165- /**
166- * Provides functions that open, commit, or rollback multi-statement
167- * transactions.
168- * @name transactions
169- * @memberof ! DatabaseClient#
170- * @type {transactions }
171- */
172- this . transactions = new transactions ( this ) ;
173-
174- /**
175- * Provides access to namespaces that configure the REST server for the client.
176- * The client must have been created for a user with the rest-admin role.
177- * @name config
178- * @memberof ! DatabaseClient#
179- * @property {config.extlibs } extlibs - provides functions that
180- * maintain the extension libraries on the REST server
181- * @property {config.serverprops } serverprops - provides functions that
182- * modify the properties of the REST server
183- * @property {config.transforms } transforms - provides functions that
184- * maintain the transform extensions on the REST server
185- */
186- this . config = {
187- extlibs : new extlibs ( this ) ,
188- serverprops : new restServerProperties ( this ) ,
189- transforms : new transforms ( this )
190- } ;
191-
192- // operation shortcuts
193- this . createReadStream = this . documents . createReadStream ;
194- this . createWriteStream = this . documents . createWriteStream ;
195- this . patch = this . documents . patch ;
196- this . probe = this . documents . probe ;
197- this . query = this . documents . query ;
198- this . read = this . documents . read ;
199- this . remove = this . documents . remove ;
200- this . removeAll = this . documents . removeAll ;
201- this . write = this . documents . write ;
202-
203- // to inspect
204- // setClientLogger.call(this, {level:'debug'});
205- }
206- MarkLogicClient . prototype . setLogger = setClientLogger ;
207- MarkLogicClient . prototype . getLogger = getClientLogger ;
208-
209241/** @ignore */
210242function MarkLogicClientFactory ( connectionParams ) {
211243 if ( arguments . length === 0 )
0 commit comments