@@ -1012,6 +1012,9 @@ WOQLClient.prototype.addDocument = function (json, params, dbId, message = 'add
1012
1012
} ;
1013
1013
1014
1014
/**
1015
+ * Use {@link #getDocument} instead.
1016
+ * @deprecated
1017
+ *
1015
1018
* Retrieves all documents that match a given document template
1016
1019
* @param {object } query - the query template
1017
1020
* @param {typedef.DocParamsGet } [params] - the get parameters
@@ -1092,6 +1095,8 @@ WOQLClient.prototype.queryDocument = function (query, params, dbId, branch, last
1092
1095
* @param {string } [lastDataVersion] the last data version tracking id.
1093
1096
* @param {boolean } [getDataVersion] If true the function will return object having result
1094
1097
* and dataVersion.
1098
+ * @param {object } [query] If a query object is provided, the function will use it to
1099
+ * query the database.
1095
1100
* @returns {Promise } A promise that returns the call response object or object having *result*
1096
1101
* and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1097
1102
* @example
@@ -1128,7 +1133,7 @@ WOQLClient.prototype.queryDocument = function (query, params, dbId, branch, last
1128
1133
* )
1129
1134
*/
1130
1135
// 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 ) {
1132
1137
if ( dbId ) {
1133
1138
this . db ( dbId ) ;
1134
1139
}
@@ -1138,6 +1143,16 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
1138
1143
if ( typeof lastDataVersion === 'string' && lastDataVersion !== '' ) {
1139
1144
this . customHeaders ( { 'TerminusDB-Data-Version' : lastDataVersion } ) ;
1140
1145
}
1146
+
1147
+ if ( query ) {
1148
+ return this . dispatch (
1149
+ CONST . QUERY_DOCUMENT ,
1150
+ this . connectionConfig . documentURL ( params ) ,
1151
+ query ,
1152
+ getDataVersion ,
1153
+ ) ;
1154
+ }
1155
+
1141
1156
return this . dispatch ( CONST . GET , this . connectionConfig . documentURL ( params ) , { } , getDataVersion ) ;
1142
1157
} ;
1143
1158
@@ -1150,6 +1165,7 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
1150
1165
* @param {string } [lastDataVersion] the last data version tracking id.
1151
1166
* @param {boolean } [getDataVersion] If true the function will return object having result
1152
1167
* and dataVersion.
1168
+ * @param {boolean } [create] If true, the function will create a new document if it doesn't exist.
1153
1169
* @returns {Promise } A promise that returns the call response object or object having *result*
1154
1170
* and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
1155
1171
* @example
@@ -1210,10 +1226,11 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
1210
1226
);
1211
1227
*/
1212
1228
1213
- WOQLClient . prototype . updateDocument = function ( json , params , dbId , message = 'update document' , lastDataVersion = '' , getDataVersion = false , compress = false ) {
1229
+ WOQLClient . prototype . updateDocument = function ( json , params , dbId , message = 'update document' , lastDataVersion = '' , getDataVersion = false , compress = false , create = false ) {
1214
1230
const docParams = params || { } ;
1215
1231
docParams . author = this . author ( ) ;
1216
1232
docParams . message = message ;
1233
+ docParams . create = create ;
1217
1234
if ( dbId ) {
1218
1235
this . db ( dbId ) ;
1219
1236
}
0 commit comments