@dnax/core 0.1.3 → 0.1.5

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.
@@ -10,6 +10,20 @@ import { Cfg } from "../../config";
10
10
  function buildPipeline(params: findParam, col?: Collection | undefined | null) {
11
11
  let pipeline = [];
12
12
 
13
+ // sorted
14
+ if (!params?.$sort?.createdAt) {
15
+ pipeline.push({
16
+ $sort: {
17
+ ...(params?.$sort || {}),
18
+ createdAt: -1,
19
+ },
20
+ });
21
+ } else {
22
+ pipeline.push({
23
+ $sort: params?.$sort,
24
+ });
25
+ }
26
+
13
27
  // $match
14
28
  if (params?.$match) {
15
29
  pipeline.push({
@@ -110,16 +124,6 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
110
124
  });
111
125
  }
112
126
 
113
- // sorted
114
- if (!params?.$sort?.createdAt) {
115
- pipeline.push({
116
- $sort: {
117
- ...(params?.$sort || {}),
118
- createdAt: -1,
119
- },
120
- });
121
- }
122
-
123
127
  // sample aleatoire
124
128
  if (params?.$sample) {
125
129
  pipeline.push({
package/lib/schema.ts CHANGED
@@ -121,7 +121,7 @@ function buildSchema(col: Collection) {
121
121
 
122
122
  if (!f?.validate?.schema) {
123
123
  if (f?.nullable) {
124
- propertySchema[f.name] = propertySchema[f.name];
124
+ propertySchema[f.name] = propertySchema[f.name].optional();
125
125
  } else {
126
126
  propertySchema[f.name] = propertySchema[f.name].required();
127
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {