@@ -1012,6 +1012,9 @@ WOQLClient.prototype.addDocument = function (json, params, dbId, message = 'add
10121012} ;
10131013
10141014/**
1015+ * Use {@link #getDocument} instead.
1016+ * @deprecated
1017+ *
10151018 * Retrieves all documents that match a given document template
10161019 * @param {object } query - the query template
10171020 * @param {typedef.DocParamsGet } [params] - the get parameters
@@ -1092,6 +1095,8 @@ WOQLClient.prototype.queryDocument = function (query, params, dbId, branch, last
10921095 * @param {string } [lastDataVersion] the last data version tracking id.
10931096 * @param {boolean } [getDataVersion] If true the function will return object having result
10941097 * and dataVersion.
1098+ * @param {object } [query] If a query object is provided, the function will use it to
1099+ * query the database.
10951100 * @returns {Promise } A promise that returns the call response object or object having *result*
10961101 * and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
10971102 * @example
@@ -1128,7 +1133,7 @@ WOQLClient.prototype.queryDocument = function (query, params, dbId, branch, last
11281133 * )
11291134 */
11301135// document interface
1131- WOQLClient . prototype . getDocument = function ( params , dbId , branch , lastDataVersion = '' , getDataVersion = false ) {
1136+ WOQLClient . prototype . getDocument = function ( params , dbId , branch , lastDataVersion = '' , getDataVersion = false , query = undefined ) {
11321137 if ( dbId ) {
11331138 this . db ( dbId ) ;
11341139 }
@@ -1138,6 +1143,16 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
11381143 if ( typeof lastDataVersion === 'string' && lastDataVersion !== '' ) {
11391144 this . customHeaders ( { 'TerminusDB-Data-Version' : lastDataVersion } ) ;
11401145 }
1146+
1147+ if ( query ) {
1148+ return this . dispatch (
1149+ CONST . QUERY_DOCUMENT ,
1150+ this . connectionConfig . documentURL ( params ) ,
1151+ query ,
1152+ getDataVersion ,
1153+ ) ;
1154+ }
1155+
11411156 return this . dispatch ( CONST . GET , this . connectionConfig . documentURL ( params ) , { } , getDataVersion ) ;
11421157} ;
11431158
0 commit comments