not-node 5.0.12 → 5.0.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "5.0.12",
3
+ "version": "5.0.15",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  ui:{
3
- component: 'UITextfield',
3
+ component: 'UIDate',
4
4
  label: 'not-node:field_createdAt_label',
5
5
  placeholder: "not-node:field_createdAt_placeholder",
6
6
  readonly: true
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  ui:{
3
- component: 'UITextfield',
3
+ component: 'UIDate',
4
4
  label: 'not-node:field_updatedAt_label',
5
5
  placeholder: 'not-node:field_updatedAt_placeholder',
6
6
  readonly: true
@@ -74,13 +74,15 @@ function sanitizeInput(input) {
74
74
  * @static
75
75
  * @param {string} id primary key
76
76
  * @param {Array} population optional if needed population of some fields
77
+ * @param {Object} condition optional if needed additional condition
77
78
  * @return {Promise} Promise
78
79
  **/
79
- function getOne(id, population = []) {
80
+ function getOne(id, population = [], condition = {}) {
80
81
  let query;
81
82
  if (this.schema.statics.__versioning) {
82
83
  query = this.findOne({
83
84
  _id: id,
85
+ ...condition,
84
86
  __latest: true,
85
87
  __closed: false
86
88
  });
@@ -91,7 +93,8 @@ function getOne(id, population = []) {
91
93
  }
92
94
  } else {
93
95
  query = this.findOne({
94
- _id: id
96
+ _id: id,
97
+ ...condition
95
98
  });
96
99
  }
97
100
  populateQuery(query, population, this.schema.statics.__versioning);
@@ -103,14 +106,18 @@ function getOne(id, population = []) {
103
106
  * If versioning ON, it retrieves __latest and not __closed
104
107
  * @static
105
108
  * @param {number} ID some unique numeric identificator
109
+ * @param {Object} condition optional if needed additional condition
106
110
  * @return {Promise} Promise of document, if increment is OFF - then Promise.resolve(null)
107
111
  **/
108
- function getOneByID(ID) {
112
+ function getOneByID(ID, condition = {}) {
109
113
  if (this.schema.statics.__incField) {
110
114
  let by = (this.schema.statics.__versioning ? {
115
+ ...condition,
111
116
  __latest: true,
112
- __closed: false
113
- } : {}),
117
+ __closed: false,
118
+ } : {
119
+ ...condition
120
+ }),
114
121
  query;
115
122
  by[this.schema.statics.__incField] = ID;
116
123
  query = this.findOne(by);
@@ -125,11 +132,13 @@ function getOneByID(ID) {
125
132
  * Retrieves one record by primary key, without any restriction
126
133
  * @static
127
134
  * @param {string} id primary key
135
+ * @param {Object} condition optional if needed additional condition
128
136
  * @return {Promise} Promise
129
137
  **/
130
- function getOneRaw(id) {
138
+ function getOneRaw(id, condition = {}) {
131
139
  let query = this.findOne({
132
- _id: id
140
+ _id: id,
141
+ ...condition
133
142
  });
134
143
  return query.exec();
135
144
  }