not-node 5.0.11 → 5.0.14
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/bin/not-builder.js +0 -0
- package/package.json +1 -1
- package/src/core/locales/en.json +8 -1
- package/src/core/locales/ru.json +9 -1
- package/src/model/default.js +16 -7
package/bin/not-builder.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/src/core/locales/en.json
CHANGED
|
@@ -46,5 +46,12 @@
|
|
|
46
46
|
"field_userId_placeholder": "UserId",
|
|
47
47
|
|
|
48
48
|
"field_UUID_label": "UUID",
|
|
49
|
-
"field_UUID_placeholder": "UUID"
|
|
49
|
+
"field_UUID_placeholder": "UUID",
|
|
50
|
+
|
|
51
|
+
"crud_create_action_waiting": "Creating record...",
|
|
52
|
+
"crud_read_action_waiting": "Reading record...",
|
|
53
|
+
"crud_update_action_waiting": "Updating record...",
|
|
54
|
+
"crud_delete_action_waiting": "Deleting record...",
|
|
55
|
+
"add_label": "Add",
|
|
56
|
+
"select_from_list_label": "Select from list..."
|
|
50
57
|
}
|
package/src/core/locales/ru.json
CHANGED
|
@@ -46,5 +46,13 @@
|
|
|
46
46
|
"field_userId_placeholder": "",
|
|
47
47
|
|
|
48
48
|
"field_UUID_label": "UUID",
|
|
49
|
-
"field_UUID_placeholder": "UUID"
|
|
49
|
+
"field_UUID_placeholder": "UUID",
|
|
50
|
+
|
|
51
|
+
"crud_create_action_waiting": "Создание записи...",
|
|
52
|
+
"crud_read_action_waiting": "Чтение записи...",
|
|
53
|
+
"crud_update_action_waiting": "Обновление записи...",
|
|
54
|
+
"crud_delete_action_waiting": "Удаление записи...",
|
|
55
|
+
"add_label": "Добавить",
|
|
56
|
+
"select_from_list_label": "Выберите из списка..."
|
|
57
|
+
|
|
50
58
|
}
|
package/src/model/default.js
CHANGED
|
@@ -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
|
}
|