expressa 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util.js +17 -2
package/package.json
CHANGED
package/util.js
CHANGED
|
@@ -53,6 +53,19 @@ exports.validateSchema = function(collection, doc) {
|
|
|
53
53
|
return true
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
exports.getSchemaProperty = function(collection, path) {
|
|
57
|
+
const parts = path.split('.')
|
|
58
|
+
let obj = schemas[collection]
|
|
59
|
+
for (const part of parts) {
|
|
60
|
+
if (obj.properties && obj.properties[part]) {
|
|
61
|
+
obj = obj.properties[part]
|
|
62
|
+
} else {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return obj
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
exports.orderBy = function (data, orderby) {
|
|
57
70
|
data.sort(function compare (a, b) {
|
|
58
71
|
for (let i = 0; i < orderby.length; i++) {
|
|
@@ -185,14 +198,16 @@ exports.mongoUpdate = function(doc, update) {
|
|
|
185
198
|
return mongoQuery(doc, {}, update)
|
|
186
199
|
}
|
|
187
200
|
|
|
201
|
+
exports.mongoToPostgres = mongoToPostgres
|
|
202
|
+
|
|
188
203
|
// paging requires orderby to include a field that is known to be unique and constant
|
|
189
204
|
// to ensure consistent results from database with offset and limit. Chosen field should
|
|
190
205
|
// also represent a preferred ordering when doing final sort
|
|
191
|
-
exports.orderByForPagedRequests = function(orderby, finalSortField = 'meta.created') {
|
|
206
|
+
exports.orderByForPagedRequests = function(orderby, finalSortField = 'meta.created', finalSortDirection = 1) {
|
|
192
207
|
orderby = exports.normalizeOrderBy(orderby || {})
|
|
193
208
|
const allFields = orderby.map(([field]) => field)
|
|
194
209
|
if (!allFields.includes(finalSortField)) {
|
|
195
|
-
orderby.push([finalSortField,
|
|
210
|
+
orderby.push([finalSortField, finalSortDirection])
|
|
196
211
|
}
|
|
197
212
|
return orderby
|
|
198
213
|
}
|