alchemymvc 1.3.21 → 1.4.0-alpha.1
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/LICENSE +1 -1
- package/README.md +3 -3
- package/lib/app/behaviour/publishable_behaviour.js +5 -5
- package/lib/app/behaviour/revision_behaviour.js +10 -10
- package/lib/app/behaviour/sluggable_behaviour.js +14 -14
- package/lib/app/conduit/electron_conduit.js +9 -9
- package/lib/app/conduit/http_conduit.js +13 -13
- package/lib/app/conduit/loopback_conduit.js +15 -15
- package/lib/app/conduit/socket_conduit.js +43 -43
- package/lib/app/config/routes.js +26 -0
- package/lib/app/controller/00-default_app_controller.js +21 -0
- package/lib/app/controller/alchemy_info_controller.js +12 -12
- package/lib/app/datasource/mongo_datasource.js +16 -16
- package/lib/app/element/00-default_app_element.js +19 -0
- package/lib/app/element/time_ago.js +5 -5
- package/lib/app/helper/00-default_app_helper.js +11 -0
- package/lib/app/helper/alchemy_helper.js +22 -22
- package/lib/app/helper/backed_map.js +1 -1
- package/lib/app/helper/breadcrumb.js +10 -10
- package/lib/app/helper/client_collection.js +3 -3
- package/lib/app/helper/cron.js +29 -29
- package/lib/app/helper/enum_values.js +6 -6
- package/lib/app/helper/pagination_helper.js +36 -36
- package/lib/app/helper/router_helper.js +35 -35
- package/lib/app/helper/socket_helper.js +57 -57
- package/lib/app/helper/syncable.js +84 -59
- package/lib/app/helper_component/paginate_component.js +9 -9
- package/lib/app/helper_controller/component.js +1 -1
- package/lib/app/helper_controller/conduit.js +31 -31
- package/lib/app/helper_controller/controller.js +54 -39
- package/lib/app/helper_datasource/00-nosql_datasource.js +624 -70
- package/lib/app/helper_datasource/05-fallback_datasource.js +10 -10
- package/lib/app/helper_datasource/idb_datasource.js +6 -6
- package/lib/app/helper_datasource/indexed_db.js +22 -22
- package/lib/app/helper_datasource/remote_datasource.js +5 -5
- package/lib/app/helper_error/http_error.js +4 -4
- package/lib/app/helper_error/model_error.js +2 -2
- package/lib/app/helper_error/validation_error.js +12 -12
- package/lib/app/helper_field/00-objectid_field.js +7 -7
- package/lib/app/helper_field/05-string_field.js +16 -12
- package/lib/app/helper_field/06-text_field.js +2 -4
- package/lib/app/helper_field/10-number_field.js +9 -12
- package/lib/app/helper_field/11-date_field.js +15 -15
- package/lib/app/helper_field/15-local_temporal_field.js +10 -10
- package/lib/app/helper_field/20-decimal_field.js +8 -9
- package/lib/app/helper_field/belongsto_field.js +1 -1
- package/lib/app/helper_field/big_int_field.js +8 -8
- package/lib/app/helper_field/boolean_field.js +9 -11
- package/lib/app/helper_field/datetime_field.js +3 -3
- package/lib/app/helper_field/enum_field.js +13 -8
- package/lib/app/helper_field/fixed_decimal_field.js +6 -7
- package/lib/app/helper_field/geopoint_field.js +9 -10
- package/lib/app/helper_field/habtm_field.js +3 -3
- package/lib/app/helper_field/hasoneparent_field.js +1 -1
- package/lib/app/helper_field/html_field.js +2 -4
- package/lib/app/helper_field/integer_field.js +8 -11
- package/lib/app/helper_field/local_date_field.js +5 -5
- package/lib/app/helper_field/local_date_time_field.js +5 -5
- package/lib/app/helper_field/local_time_field.js +5 -5
- package/lib/app/helper_field/mixed_field.js +5 -5
- package/lib/app/helper_field/object_field.js +8 -8
- package/lib/app/helper_field/password_field.js +3 -3
- package/lib/app/helper_field/regexp_field.js +7 -9
- package/lib/app/helper_field/schema_field.js +91 -88
- package/lib/app/helper_field/settings_field.js +92 -0
- package/lib/app/helper_field/time_field.js +6 -6
- package/lib/app/helper_field/url_field.js +2 -4
- package/lib/app/helper_model/00-base_criteria.js +662 -0
- package/lib/app/helper_model/05-criteria_expressions.js +605 -0
- package/lib/app/helper_model/10-model_criteria.js +1182 -0
- package/lib/app/helper_model/data_provider.js +2 -2
- package/lib/app/helper_model/document.js +103 -92
- package/lib/app/helper_model/document_list.js +14 -14
- package/lib/app/helper_model/field_config.js +11 -11
- package/lib/app/helper_model/field_set.js +17 -17
- package/lib/app/helper_model/model.js +203 -124
- package/lib/app/helper_model/remote_data_provider.js +2 -2
- package/lib/app/helper_validator/00_validator.js +16 -16
- package/lib/app/helper_validator/not_empty_validator.js +9 -9
- package/lib/app/model/00-default_app_model.js +18 -0
- package/lib/app/model/05-system_model.js +27 -0
- package/lib/app/model/{alchemy_migration_model.js → system_migration_model.js} +4 -4
- package/lib/app/model/system_setting_model.js +154 -0
- package/lib/app/model/{alchemy_task_history_model.js → system_task_history_model.js} +7 -7
- package/lib/app/model/{alchemy_task_model.js → system_task_model.js} +11 -11
- package/lib/bootstrap.js +22 -312
- package/lib/class/accumulator.js +5 -5
- package/lib/class/behaviour.js +5 -5
- package/lib/class/component.js +3 -3
- package/lib/class/conduit.js +203 -163
- package/lib/class/controller.js +42 -42
- package/lib/class/datasource.js +74 -79
- package/lib/class/document.js +74 -95
- package/lib/class/document_list.js +5 -5
- package/lib/class/element.js +17 -17
- package/lib/class/error.js +3 -3
- package/lib/class/field.js +169 -91
- package/lib/class/field_value.js +6 -6
- package/lib/class/helper.js +3 -3
- package/lib/class/inode.js +17 -17
- package/lib/class/inode_dir.js +12 -12
- package/lib/class/inode_file.js +50 -25
- package/lib/class/inode_list.js +4 -4
- package/lib/class/migration.js +4 -4
- package/lib/class/model.js +182 -168
- package/lib/class/path_definition.js +22 -22
- package/lib/class/path_evaluator.js +5 -5
- package/lib/class/path_param_definition.js +7 -7
- package/lib/class/plugin.js +312 -0
- package/lib/class/postponement.js +29 -29
- package/lib/class/reciprocal.js +8 -8
- package/lib/class/route.js +33 -33
- package/lib/class/router.js +73 -73
- package/lib/class/schema.js +21 -21
- package/lib/class/schema_client.js +73 -67
- package/lib/class/session.js +63 -29
- package/lib/class/session_scene.js +4 -4
- package/lib/class/sitemap.js +16 -16
- package/lib/class/task.js +39 -39
- package/lib/class/task_service.js +43 -47
- package/lib/{init → core}/alchemy.js +413 -374
- package/lib/{init/functions.js → core/alchemy_functions.js} +171 -108
- package/lib/core/alchemy_load_functions.js +715 -0
- package/lib/core/base.js +50 -62
- package/lib/core/client_alchemy.js +144 -152
- package/lib/core/client_base.js +39 -52
- package/lib/core/discovery.js +16 -18
- package/lib/core/middleware.js +54 -43
- package/lib/core/{routing.js → prefix.js} +14 -16
- package/lib/core/setting.js +1684 -0
- package/lib/core/stage.js +758 -0
- package/lib/scripts/create_constants.js +119 -0
- package/lib/{init/languages.js → scripts/create_languages.js} +5 -5
- package/lib/scripts/create_settings.js +449 -0
- package/lib/scripts/create_shared_constants.js +95 -0
- package/lib/scripts/create_stages.js +55 -0
- package/lib/scripts/init_alchemy.js +51 -0
- package/lib/{init/requirements.js → scripts/preload_modules.js} +15 -2
- package/lib/scripts/setup_devwatch.js +238 -0
- package/lib/stages/00-load_core.js +342 -0
- package/lib/stages/05-load_app.js +57 -0
- package/lib/stages/10-datasource.js +61 -0
- package/lib/stages/15-tasks.js +27 -0
- package/lib/stages/20-settings.js +68 -0
- package/lib/stages/50-routes.js +218 -0
- package/lib/stages/90-server.js +347 -0
- package/package.json +5 -7
- package/lib/app/helper_model/criteria.js +0 -2294
- package/lib/app/helper_model/db_query.js +0 -1488
- package/lib/app/routes.js +0 -11
- package/lib/core/socket.js +0 -171
- package/lib/init/constants.js +0 -158
- package/lib/init/devwatch.js +0 -238
- package/lib/init/load_functions.js +0 -973
- package/lib/stages.js +0 -513
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const CriteriaNS = Function.getNamespace('Alchemy.Criteria');
|
|
2
|
+
|
|
1
3
|
let class_cache = new Map(),
|
|
2
4
|
fallback_datasource,
|
|
3
5
|
TABLE = Symbol('table');
|
|
@@ -10,7 +12,7 @@ if (Blast.isBrowser) {
|
|
|
10
12
|
for (config of hawkejs.scene.exposed.model_info) {
|
|
11
13
|
// First get or create the client-side Model class,
|
|
12
14
|
// then set some extra configuration coming from the server-side
|
|
13
|
-
Model.getClass(config.
|
|
15
|
+
Model.getClass(config.model_name).setModelConfig(config);
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
}
|
|
@@ -21,7 +23,7 @@ if (Blast.isBrowser) {
|
|
|
21
23
|
*
|
|
22
24
|
* @constructor
|
|
23
25
|
*
|
|
24
|
-
* @author Jelle De Loecker
|
|
26
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
25
27
|
* @since 1.0.0
|
|
26
28
|
* @version 1.1.0
|
|
27
29
|
*
|
|
@@ -34,22 +36,54 @@ const Model = Function.inherits('Alchemy.Client.Base', 'Alchemy.Client.Model', f
|
|
|
34
36
|
/**
|
|
35
37
|
* Set the modelName property after class creation
|
|
36
38
|
*
|
|
37
|
-
* @author Jelle De Loecker
|
|
39
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
38
40
|
* @since 1.1.0
|
|
39
|
-
* @version 1.
|
|
41
|
+
* @version 1.4.0
|
|
40
42
|
*/
|
|
41
|
-
Model.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
Model.postInherit(function setModelName() {
|
|
44
|
+
|
|
45
|
+
let base_name = this.name;
|
|
46
|
+
let model_name = base_name;
|
|
47
|
+
let table_prefix = this.table_prefix;
|
|
48
|
+
let namespace = this.namespace;
|
|
49
|
+
|
|
50
|
+
if (namespace.startsWith('Alchemy.Model.') || namespace == 'Alchemy.Model') {
|
|
51
|
+
namespace = namespace.slice(14);
|
|
52
|
+
} else if (namespace.startsWith('Alchemy.Client.Model.') || namespace == 'Alchemy.Client.Model') {
|
|
53
|
+
namespace = namespace.slice(21);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.setStatic('model_namespace', namespace, false);
|
|
57
|
+
|
|
58
|
+
let ns = namespace.replaceAll('.', '_');
|
|
59
|
+
|
|
60
|
+
if (!table_prefix && ns) {
|
|
61
|
+
table_prefix = ns.tableize();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (ns) {
|
|
65
|
+
model_name = ns + '_' + model_name;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The simple name of the model
|
|
69
|
+
this.model_name = model_name;
|
|
70
|
+
this.setProperty('model_name', model_name);
|
|
71
|
+
|
|
72
|
+
let table_name = base_name.tableize();
|
|
73
|
+
|
|
74
|
+
if (table_prefix) {
|
|
75
|
+
table_name = table_prefix + '_' + table_name;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.table = table_name;
|
|
45
79
|
});
|
|
46
80
|
|
|
47
81
|
/**
|
|
48
82
|
* Map these events to methods
|
|
49
83
|
*
|
|
50
|
-
* @author Jelle De Loecker
|
|
84
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
51
85
|
* @since 1.2.5
|
|
52
|
-
* @version 1.
|
|
86
|
+
* @version 1.3.22
|
|
53
87
|
*/
|
|
54
88
|
Model.mapEventToMethod({
|
|
55
89
|
saved : 'afterSave',
|
|
@@ -58,18 +92,19 @@ Model.mapEventToMethod({
|
|
|
58
92
|
associated : 'afterAssociated',
|
|
59
93
|
found : 'afterData',
|
|
60
94
|
foundDocuments : 'afterFind',
|
|
95
|
+
removed : 'afterRemove',
|
|
61
96
|
});
|
|
62
97
|
|
|
63
98
|
/**
|
|
64
99
|
* Is the given action enabled on the server?
|
|
65
100
|
*
|
|
66
|
-
* @author Jelle De Loecker
|
|
101
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
67
102
|
* @since 1.0.6
|
|
68
103
|
* @version 1.0.6
|
|
69
104
|
*
|
|
70
|
-
* @param {
|
|
105
|
+
* @param {string} action
|
|
71
106
|
*
|
|
72
|
-
* @return {
|
|
107
|
+
* @return {boolean}
|
|
73
108
|
*/
|
|
74
109
|
Model.setStatic(function hasServerAction(action) {
|
|
75
110
|
|
|
@@ -88,7 +123,7 @@ Model.setStatic(function hasServerAction(action) {
|
|
|
88
123
|
/**
|
|
89
124
|
* Set the Model configuration
|
|
90
125
|
*
|
|
91
|
-
* @author Jelle De Loecker
|
|
126
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
92
127
|
* @since 1.3.1
|
|
93
128
|
* @version 1.3.1
|
|
94
129
|
*
|
|
@@ -113,7 +148,7 @@ Model.setStatic(function setModelConfig(config) {
|
|
|
113
148
|
* Table name to use in the database.
|
|
114
149
|
* False if no table should be used.
|
|
115
150
|
*
|
|
116
|
-
* @type
|
|
151
|
+
* @type {string}
|
|
117
152
|
*/
|
|
118
153
|
Model.setProperty(function table() {
|
|
119
154
|
|
|
@@ -129,7 +164,7 @@ Model.setProperty(function table() {
|
|
|
129
164
|
/**
|
|
130
165
|
* The datasource
|
|
131
166
|
*
|
|
132
|
-
* @author Jelle De Loecker <jelle@
|
|
167
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
133
168
|
* @since 1.0.0
|
|
134
169
|
* @version 1.1.7
|
|
135
170
|
*
|
|
@@ -168,7 +203,7 @@ Model.setProperty(function datasource() {
|
|
|
168
203
|
* @since 1.3.0
|
|
169
204
|
* @version 1.3.0
|
|
170
205
|
*
|
|
171
|
-
* @type {
|
|
206
|
+
* @type {boolean}
|
|
172
207
|
*/
|
|
173
208
|
Model.setProperty(function has_translatable_fields() {
|
|
174
209
|
return this.schema.has_translatable_fields;
|
|
@@ -177,7 +212,7 @@ Model.setProperty(function has_translatable_fields() {
|
|
|
177
212
|
/**
|
|
178
213
|
* The conduit
|
|
179
214
|
*
|
|
180
|
-
* @author Jelle De Loecker <jelle@
|
|
215
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
181
216
|
* @since 1.0.4
|
|
182
217
|
* @version 1.0.4
|
|
183
218
|
*/
|
|
@@ -209,7 +244,7 @@ Model.setProperty(function conduit() {
|
|
|
209
244
|
/**
|
|
210
245
|
* Get the document class constructor
|
|
211
246
|
*
|
|
212
|
-
* @type
|
|
247
|
+
* @type {Hawkejs.Document}
|
|
213
248
|
*/
|
|
214
249
|
Model.prepareStaticProperty('Document', function getDocumentClass() {
|
|
215
250
|
return Blast.Classes.Alchemy.Client.Document.Document.getDocumentClass(this);
|
|
@@ -218,25 +253,36 @@ Model.prepareStaticProperty('Document', function getDocumentClass() {
|
|
|
218
253
|
/**
|
|
219
254
|
* Create client model class for specific model name
|
|
220
255
|
*
|
|
221
|
-
* @author Jelle De Loecker <jelle@
|
|
256
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
222
257
|
* @since 1.0.0
|
|
223
|
-
* @version 1.
|
|
258
|
+
* @version 1.4.0
|
|
224
259
|
*
|
|
225
|
-
* @param {
|
|
226
|
-
* @param {
|
|
227
|
-
* @param {
|
|
260
|
+
* @param {string} model_name
|
|
261
|
+
* @param {boolean} allow_create
|
|
262
|
+
* @param {string} parent
|
|
228
263
|
*/
|
|
229
264
|
Model.setStatic(function getClass(model_name, allow_create, parent) {
|
|
230
265
|
|
|
231
|
-
|
|
232
|
-
|
|
266
|
+
let cache_key = model_name;
|
|
267
|
+
|
|
268
|
+
if (class_cache.has(cache_key)) {
|
|
269
|
+
return class_cache.get(cache_key);
|
|
233
270
|
}
|
|
234
271
|
|
|
272
|
+
// Get the model path as an array
|
|
273
|
+
let model_path = Blast.parseClassPath(model_name);
|
|
274
|
+
|
|
275
|
+
// Ensure it is the correct model_name
|
|
276
|
+
model_name = model_path.join('_');
|
|
277
|
+
|
|
235
278
|
// Construct the name of the class
|
|
236
|
-
let class_name =
|
|
279
|
+
let class_name = model_path.last();
|
|
280
|
+
|
|
281
|
+
// The root path
|
|
282
|
+
const root_path = 'Alchemy.Client.Model';
|
|
237
283
|
|
|
238
|
-
// Construct the path to this class
|
|
239
|
-
let class_path = '
|
|
284
|
+
// Construct the expected path to this class
|
|
285
|
+
let class_path = root_path + '.' + model_path.join('.');
|
|
240
286
|
|
|
241
287
|
// Get the class
|
|
242
288
|
let ModelClass = Object.path(Blast.Classes, class_path);
|
|
@@ -246,39 +292,39 @@ Model.setStatic(function getClass(model_name, allow_create, parent) {
|
|
|
246
292
|
}
|
|
247
293
|
|
|
248
294
|
if (ModelClass == null && allow_create) {
|
|
249
|
-
|
|
295
|
+
|
|
296
|
+
let namespace = root_path,
|
|
297
|
+
config;
|
|
298
|
+
|
|
299
|
+
if (model_path.length > 1) {
|
|
300
|
+
namespace += '.' + model_path.slice(0, -1).join('.');
|
|
301
|
+
}
|
|
250
302
|
|
|
251
303
|
let model_constructor = Function.create(class_name, function ModelConstructor(record, options) {
|
|
252
|
-
ModelConstructor.
|
|
304
|
+
ModelConstructor.super.call(this, record, options);
|
|
253
305
|
});
|
|
254
306
|
|
|
255
|
-
// @TODO: inherit from parents
|
|
256
|
-
let parent_path = 'Alchemy.Client.Model';
|
|
257
|
-
|
|
258
307
|
if (Blast.isBrowser) {
|
|
259
|
-
// No longer needed
|
|
260
|
-
} else if (Blast.isNode) {
|
|
261
|
-
config = alchemy.getModel(model_name, false);
|
|
262
308
|
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
};
|
|
309
|
+
if (parent) {
|
|
310
|
+
let parent_model_path = Blast.parseClassPath(parent);
|
|
311
|
+
parent = root_path + '.' + parent_model_path.join('.');
|
|
312
|
+
} else {
|
|
313
|
+
parent = root_path;
|
|
269
314
|
}
|
|
270
|
-
}
|
|
271
315
|
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
316
|
+
} else if (Blast.isNode) {
|
|
317
|
+
let server_class = alchemy.getModel(model_name, false);
|
|
318
|
+
|
|
319
|
+
parent = getClass(server_class.super.model_name);
|
|
275
320
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
321
|
+
config = {
|
|
322
|
+
primary_key : server_class.prototype.primary_key,
|
|
323
|
+
display_field : server_class.prototype.display_field,
|
|
324
|
+
};
|
|
279
325
|
}
|
|
280
326
|
|
|
281
|
-
ModelClass = Function.inherits(
|
|
327
|
+
ModelClass = Function.inherits(parent, namespace, model_constructor);
|
|
282
328
|
|
|
283
329
|
ModelClass.setProperty('$model_name', model_name);
|
|
284
330
|
|
|
@@ -297,7 +343,7 @@ Model.setStatic(function getClass(model_name, allow_create, parent) {
|
|
|
297
343
|
}
|
|
298
344
|
}
|
|
299
345
|
|
|
300
|
-
class_cache.set(
|
|
346
|
+
class_cache.set(cache_key, ModelClass);
|
|
301
347
|
|
|
302
348
|
return ModelClass;
|
|
303
349
|
});
|
|
@@ -305,9 +351,9 @@ Model.setStatic(function getClass(model_name, allow_create, parent) {
|
|
|
305
351
|
/**
|
|
306
352
|
* Set a method on the hawkejs document class
|
|
307
353
|
*
|
|
308
|
-
* @author Jelle De Loecker
|
|
354
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
309
355
|
* @since 1.0.0
|
|
310
|
-
* @version 1.
|
|
356
|
+
* @version 1.4.0
|
|
311
357
|
*/
|
|
312
358
|
Model.setStatic(function setDocumentMethod(name, fnc, on_server) {
|
|
313
359
|
|
|
@@ -320,7 +366,7 @@ Model.setStatic(function setDocumentMethod(name, fnc, on_server) {
|
|
|
320
366
|
}
|
|
321
367
|
|
|
322
368
|
if (Blast.isNode) {
|
|
323
|
-
|
|
369
|
+
STAGES.afterStages('load_app.plugins', whenLoaded);
|
|
324
370
|
} else {
|
|
325
371
|
Blast.loaded(whenLoaded);
|
|
326
372
|
}
|
|
@@ -333,9 +379,9 @@ Model.setStatic(function setDocumentMethod(name, fnc, on_server) {
|
|
|
333
379
|
/**
|
|
334
380
|
* Set a property on the hawkejs document class
|
|
335
381
|
*
|
|
336
|
-
* @author Jelle De Loecker
|
|
382
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
337
383
|
* @since 1.0.0
|
|
338
|
-
* @version 1.
|
|
384
|
+
* @version 1.4.0
|
|
339
385
|
*/
|
|
340
386
|
Model.setStatic(function setDocumentProperty(key, getter, setter, on_server) {
|
|
341
387
|
|
|
@@ -343,7 +389,7 @@ Model.setStatic(function setDocumentProperty(key, getter, setter, on_server) {
|
|
|
343
389
|
args = arguments;
|
|
344
390
|
|
|
345
391
|
if (Blast.isNode) {
|
|
346
|
-
|
|
392
|
+
STAGES.afterStages('load_app.plugins', whenLoaded);
|
|
347
393
|
} else {
|
|
348
394
|
Blast.loaded(whenLoaded);
|
|
349
395
|
}
|
|
@@ -356,7 +402,7 @@ Model.setStatic(function setDocumentProperty(key, getter, setter, on_server) {
|
|
|
356
402
|
/**
|
|
357
403
|
* The schema
|
|
358
404
|
*
|
|
359
|
-
* @type
|
|
405
|
+
* @type {Schema}
|
|
360
406
|
*/
|
|
361
407
|
Model.setStaticProperty(function schema() {
|
|
362
408
|
if (this.prototype.model_info) {
|
|
@@ -367,7 +413,7 @@ Model.setStaticProperty(function schema() {
|
|
|
367
413
|
/**
|
|
368
414
|
* The model name
|
|
369
415
|
*
|
|
370
|
-
* @type
|
|
416
|
+
* @type {string}
|
|
371
417
|
*/
|
|
372
418
|
Model.setProperty(function name() {
|
|
373
419
|
return this._name || this.constructor.model_name;
|
|
@@ -378,7 +424,7 @@ Model.setProperty(function name() {
|
|
|
378
424
|
/**
|
|
379
425
|
* Initialize the model
|
|
380
426
|
*
|
|
381
|
-
* @author Jelle De Loecker
|
|
427
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
382
428
|
* @since 1.1.0
|
|
383
429
|
* @version 1.3.0
|
|
384
430
|
*
|
|
@@ -412,7 +458,7 @@ Model.setMethod(function init(options) {
|
|
|
412
458
|
*
|
|
413
459
|
* @deprecated
|
|
414
460
|
*
|
|
415
|
-
* @author Jelle De Loecker
|
|
461
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
416
462
|
* @since 0.2.0
|
|
417
463
|
* @version 1.0.0
|
|
418
464
|
*
|
|
@@ -455,14 +501,14 @@ Model.setMethod(function getFindOptions(options) {
|
|
|
455
501
|
/**
|
|
456
502
|
* Get the title to display for this record
|
|
457
503
|
*
|
|
458
|
-
* @author Jelle De Loecker
|
|
504
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
459
505
|
* @since 0.0.1
|
|
460
506
|
* @version 1.3.14
|
|
461
507
|
*
|
|
462
508
|
* @param {Object} item The record item of this model
|
|
463
|
-
* @param {
|
|
509
|
+
* @param {string|Array} fallbacks Extra fallbacks to use
|
|
464
510
|
*
|
|
465
|
-
* @return {
|
|
511
|
+
* @return {string} The display title to use
|
|
466
512
|
*/
|
|
467
513
|
Model.setMethod(function getDisplayTitleOrNull(item, fallbacks) {
|
|
468
514
|
|
|
@@ -514,14 +560,14 @@ Model.setMethod(function getDisplayTitleOrNull(item, fallbacks) {
|
|
|
514
560
|
/**
|
|
515
561
|
* Get the title to display for this record
|
|
516
562
|
*
|
|
517
|
-
* @author Jelle De Loecker
|
|
563
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
518
564
|
* @since 0.0.1
|
|
519
565
|
* @version 1.3.16
|
|
520
566
|
*
|
|
521
567
|
* @param {Object} item The record item of this model
|
|
522
|
-
* @param {
|
|
568
|
+
* @param {string|Array} fallbacks Extra fallbacks to use
|
|
523
569
|
*
|
|
524
|
-
* @return {
|
|
570
|
+
* @return {string} The display title to use
|
|
525
571
|
*/
|
|
526
572
|
Model.setMethod(function getDisplayTitle(item, fallbacks) {
|
|
527
573
|
|
|
@@ -545,11 +591,11 @@ Model.setMethod(function getDisplayTitle(item, fallbacks) {
|
|
|
545
591
|
/**
|
|
546
592
|
* Return association configuration
|
|
547
593
|
*
|
|
548
|
-
* @author Jelle De Loecker
|
|
594
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
549
595
|
* @since 1.1.0
|
|
550
596
|
* @version 1.2.0
|
|
551
597
|
*
|
|
552
|
-
* @param {
|
|
598
|
+
* @param {string} alias
|
|
553
599
|
*
|
|
554
600
|
* @return {Object}
|
|
555
601
|
*/
|
|
@@ -594,11 +640,11 @@ Model.setMethod(function getAssociation(alias) {
|
|
|
594
640
|
/**
|
|
595
641
|
* Return a model instance for the given alias
|
|
596
642
|
*
|
|
597
|
-
* @author Jelle De Loecker
|
|
643
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
598
644
|
* @since 0.2.0
|
|
599
645
|
* @version 1.0.0
|
|
600
646
|
*
|
|
601
|
-
* @param {
|
|
647
|
+
* @param {string} alias
|
|
602
648
|
*
|
|
603
649
|
* @return {Model}
|
|
604
650
|
*/
|
|
@@ -624,23 +670,55 @@ Model.setMethod(function getAliasModel(alias) {
|
|
|
624
670
|
return result;
|
|
625
671
|
});
|
|
626
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Find one record
|
|
675
|
+
*
|
|
676
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
677
|
+
* @since 1.4.0
|
|
678
|
+
* @version 1.4.0
|
|
679
|
+
*
|
|
680
|
+
* @param {string|Object|Criteria} conditions
|
|
681
|
+
*
|
|
682
|
+
* @return {Pledge|Criteria}
|
|
683
|
+
*/
|
|
684
|
+
Model.setMethod(function findOne(conditions, options) {
|
|
685
|
+
conditions = CriteriaNS.Model.cast(conditions, options, this);
|
|
686
|
+
return this.find('first', conditions);
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Find all records
|
|
691
|
+
*
|
|
692
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
693
|
+
* @since 1.4.0
|
|
694
|
+
* @version 1.4.0
|
|
695
|
+
*
|
|
696
|
+
* @param {string|Object|Criteria} conditions
|
|
697
|
+
*
|
|
698
|
+
* @return {Pledge|Criteria}
|
|
699
|
+
*/
|
|
700
|
+
Model.setMethod(function findAll(conditions, options) {
|
|
701
|
+
conditions = CriteriaNS.Model.cast(conditions, options, this);
|
|
702
|
+
return this.find('all', conditions);
|
|
703
|
+
});
|
|
704
|
+
|
|
627
705
|
/**
|
|
628
706
|
* Query the database
|
|
629
707
|
*
|
|
630
|
-
* @author Jelle De Loecker
|
|
708
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
631
709
|
* @since 0.0.1
|
|
632
|
-
* @version 1.
|
|
710
|
+
* @version 1.4.0
|
|
633
711
|
*
|
|
634
|
-
* @param {
|
|
712
|
+
* @param {string} type The type of find (first, all)
|
|
635
713
|
* @param {Criteria} criteria The criteria object
|
|
636
714
|
* @param {Function} callback
|
|
637
715
|
*
|
|
638
|
-
* @
|
|
716
|
+
* @return {Pledge|Criteria}
|
|
639
717
|
*/
|
|
640
718
|
Model.setMethod(function find(type, criteria, callback) {
|
|
641
719
|
|
|
642
720
|
if (arguments.length == 0) {
|
|
643
|
-
return new
|
|
721
|
+
return new Classes.Alchemy.Criteria.Model(this);
|
|
644
722
|
}
|
|
645
723
|
|
|
646
724
|
let skip_type,
|
|
@@ -648,13 +726,13 @@ Model.setMethod(function find(type, criteria, callback) {
|
|
|
648
726
|
error;
|
|
649
727
|
|
|
650
728
|
if (!this.datasource) {
|
|
651
|
-
pledge = new
|
|
729
|
+
pledge = new Pledge();
|
|
652
730
|
pledge.done(callback);
|
|
653
731
|
pledge.reject(new Classes.Alchemy.Error.Model('Unable to perform ' + this.constructor.name + '#find(), no datasource is available'));
|
|
654
732
|
return pledge;
|
|
655
733
|
}
|
|
656
734
|
|
|
657
|
-
if (
|
|
735
|
+
if (Classes.Alchemy.Criteria.Criteria.isCriteria(type)) {
|
|
658
736
|
callback = criteria;
|
|
659
737
|
criteria = type;
|
|
660
738
|
type = null;
|
|
@@ -673,13 +751,13 @@ Model.setMethod(function find(type, criteria, callback) {
|
|
|
673
751
|
}
|
|
674
752
|
|
|
675
753
|
try {
|
|
676
|
-
criteria =
|
|
754
|
+
criteria = Classes.Alchemy.Criteria.Model.cast(criteria, this);
|
|
677
755
|
} catch (err) {
|
|
678
756
|
error = err;
|
|
679
757
|
}
|
|
680
758
|
|
|
681
759
|
if (error != null) {
|
|
682
|
-
pledge = new
|
|
760
|
+
pledge = new Pledge();
|
|
683
761
|
pledge.done(callback);
|
|
684
762
|
pledge.reject(error);
|
|
685
763
|
return pledge;
|
|
@@ -856,11 +934,11 @@ Model.setMethod(function find(type, criteria, callback) {
|
|
|
856
934
|
/**
|
|
857
935
|
* Query the database by a single id
|
|
858
936
|
*
|
|
859
|
-
* @author Jelle De Loecker
|
|
937
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
860
938
|
* @since 0.0.1
|
|
861
939
|
* @version 1.1.0
|
|
862
940
|
*
|
|
863
|
-
* @param {
|
|
941
|
+
* @param {string|ObjectId} id The object id as string or object
|
|
864
942
|
* @param {Object} options Optional options object
|
|
865
943
|
* @param {Function} callback
|
|
866
944
|
*
|
|
@@ -873,11 +951,11 @@ Model.setMethod(function findById(id, options, callback) {
|
|
|
873
951
|
/**
|
|
874
952
|
* Query the database by a single id
|
|
875
953
|
*
|
|
876
|
-
* @author Jelle De Loecker
|
|
954
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
877
955
|
* @since 0.0.1
|
|
878
|
-
* @version 1.
|
|
956
|
+
* @version 1.4.0
|
|
879
957
|
*
|
|
880
|
-
* @param {
|
|
958
|
+
* @param {string|ObjectId} pk The primary key value
|
|
881
959
|
* @param {Object} options Optional options object
|
|
882
960
|
* @param {Function} callback
|
|
883
961
|
*
|
|
@@ -891,7 +969,7 @@ Model.setMethod(function findByPk(pk, options, callback) {
|
|
|
891
969
|
return pledge;
|
|
892
970
|
}
|
|
893
971
|
|
|
894
|
-
let criteria = new
|
|
972
|
+
let criteria = new Classes.Alchemy.Criteria.Model(this);
|
|
895
973
|
|
|
896
974
|
criteria.where(this.primary_key).equals(pk);
|
|
897
975
|
|
|
@@ -907,9 +985,9 @@ Model.setMethod(function findByPk(pk, options, callback) {
|
|
|
907
985
|
/**
|
|
908
986
|
* Query the database by key-val attributes, return the first result
|
|
909
987
|
*
|
|
910
|
-
* @author Jelle De Loecker
|
|
988
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
911
989
|
* @since 1.1.0
|
|
912
|
-
* @version 1.
|
|
990
|
+
* @version 1.4.0
|
|
913
991
|
*
|
|
914
992
|
* @param {Object} values The values to look for
|
|
915
993
|
* @param {Object} options Optional options object
|
|
@@ -918,7 +996,7 @@ Model.setMethod(function findByPk(pk, options, callback) {
|
|
|
918
996
|
*/
|
|
919
997
|
Model.setMethod(function findByValues(values, options) {
|
|
920
998
|
|
|
921
|
-
var criteria = new
|
|
999
|
+
var criteria = new Classes.Alchemy.Criteria.Model(this),
|
|
922
1000
|
key;
|
|
923
1001
|
|
|
924
1002
|
if (options) {
|
|
@@ -935,9 +1013,9 @@ Model.setMethod(function findByValues(values, options) {
|
|
|
935
1013
|
/**
|
|
936
1014
|
* Query the database by key-val attributes, return all results
|
|
937
1015
|
*
|
|
938
|
-
* @author Jelle De Loecker
|
|
1016
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
939
1017
|
* @since 1.1.0
|
|
940
|
-
* @version 1.
|
|
1018
|
+
* @version 1.4.0
|
|
941
1019
|
*
|
|
942
1020
|
* @param {Object} values The values to look for
|
|
943
1021
|
* @param {Object} options Optional options object
|
|
@@ -946,7 +1024,7 @@ Model.setMethod(function findByValues(values, options) {
|
|
|
946
1024
|
*/
|
|
947
1025
|
Model.setMethod(function findAllByValues(values, options) {
|
|
948
1026
|
|
|
949
|
-
var criteria = new
|
|
1027
|
+
var criteria = new Classes.Alchemy.Criteria.Model(this),
|
|
950
1028
|
key;
|
|
951
1029
|
|
|
952
1030
|
if (options) {
|
|
@@ -963,7 +1041,7 @@ Model.setMethod(function findAllByValues(values, options) {
|
|
|
963
1041
|
/**
|
|
964
1042
|
* The 'first' find method
|
|
965
1043
|
*
|
|
966
|
-
* @author Jelle De Loecker
|
|
1044
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
967
1045
|
* @since 0.0.1
|
|
968
1046
|
* @version 1.1.0
|
|
969
1047
|
*
|
|
@@ -984,7 +1062,7 @@ Model.setMethod(function beforeFindFirst(criteria, callback) {
|
|
|
984
1062
|
/**
|
|
985
1063
|
* The 'list' find method
|
|
986
1064
|
*
|
|
987
|
-
* @author Jelle De Loecker
|
|
1065
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
988
1066
|
* @since 0.0.1
|
|
989
1067
|
* @version 1.1.0
|
|
990
1068
|
*
|
|
@@ -1008,7 +1086,7 @@ Model.setMethod(function beforeFindList(criteria, callback) {
|
|
|
1008
1086
|
/**
|
|
1009
1087
|
* The 'dict' find method
|
|
1010
1088
|
*
|
|
1011
|
-
* @author Jelle De Loecker
|
|
1089
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1012
1090
|
* @since 0.0.1
|
|
1013
1091
|
* @version 1.1.0
|
|
1014
1092
|
*
|
|
@@ -1022,7 +1100,7 @@ Model.setMethod(function beforeFindDict(criteria, callback) {
|
|
|
1022
1100
|
/**
|
|
1023
1101
|
* The 'count' find method
|
|
1024
1102
|
*
|
|
1025
|
-
* @author Jelle De Loecker
|
|
1103
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1026
1104
|
* @since 0.0.1
|
|
1027
1105
|
* @version 1.1.0
|
|
1028
1106
|
*
|
|
@@ -1043,7 +1121,7 @@ Model.setMethod(function beforeFindCount(criteria, callback) {
|
|
|
1043
1121
|
/**
|
|
1044
1122
|
* The 'list' find method
|
|
1045
1123
|
*
|
|
1046
|
-
* @author Jelle De Loecker
|
|
1124
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1047
1125
|
* @since 0.2.0
|
|
1048
1126
|
* @version 1.1.0
|
|
1049
1127
|
*
|
|
@@ -1096,7 +1174,7 @@ Model.setMethod(function afterFindList(criteria, records, callback) {
|
|
|
1096
1174
|
/**
|
|
1097
1175
|
* The 'dict' find method
|
|
1098
1176
|
*
|
|
1099
|
-
* @author Jelle De Loecker
|
|
1177
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1100
1178
|
* @since 0.2.0
|
|
1101
1179
|
* @version 0.2.0
|
|
1102
1180
|
*/
|
|
@@ -1139,7 +1217,7 @@ Model.setMethod(function afterFindDict(options, records, callback) {
|
|
|
1139
1217
|
/**
|
|
1140
1218
|
* The 'count' find method
|
|
1141
1219
|
*
|
|
1142
|
-
* @author Jelle De Loecker
|
|
1220
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1143
1221
|
* @since 0.2.0
|
|
1144
1222
|
* @version 0.4.0
|
|
1145
1223
|
*/
|
|
@@ -1150,7 +1228,7 @@ Model.setMethod(function afterFindCount(options, records, callback) {
|
|
|
1150
1228
|
/**
|
|
1151
1229
|
* Add associated data to a single record
|
|
1152
1230
|
*
|
|
1153
|
-
* @author Jelle De Loecker
|
|
1231
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1154
1232
|
* @since 0.1.0
|
|
1155
1233
|
* @version 1.1.5
|
|
1156
1234
|
*
|
|
@@ -1329,7 +1407,7 @@ Model.setMethod(function addAssociatedDataToRecord(criteria, item, callback) {
|
|
|
1329
1407
|
};
|
|
1330
1408
|
});
|
|
1331
1409
|
|
|
1332
|
-
pledge = Function.parallel(alchemy.settings.model_assoc_parallel_limit || 4, aliases, function gotAssociatedList(err, list) {
|
|
1410
|
+
pledge = Function.parallel(alchemy.settings.data_management.model_assoc_parallel_limit || 4, aliases, function gotAssociatedList(err, list) {
|
|
1333
1411
|
|
|
1334
1412
|
if (err != null) {
|
|
1335
1413
|
console.log('ERROR: ' + err, err);
|
|
@@ -1350,11 +1428,11 @@ Model.setMethod(function addAssociatedDataToRecord(criteria, item, callback) {
|
|
|
1350
1428
|
/**
|
|
1351
1429
|
* Save (mixed) data to the database
|
|
1352
1430
|
*
|
|
1353
|
-
* @author Jelle De Loecker
|
|
1431
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1354
1432
|
* @since 0.0.1
|
|
1355
1433
|
* @version 1.0.7
|
|
1356
1434
|
*
|
|
1357
|
-
* @return
|
|
1435
|
+
* @return {Pledge}
|
|
1358
1436
|
*/
|
|
1359
1437
|
Model.setMethod(function save(data, _options, _callback) {
|
|
1360
1438
|
|
|
@@ -1446,7 +1524,7 @@ Model.setMethod(function save(data, _options, _callback) {
|
|
|
1446
1524
|
* Create a new document.
|
|
1447
1525
|
* If data is given, the document is populated
|
|
1448
1526
|
*
|
|
1449
|
-
* @author Jelle De Loecker
|
|
1527
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1450
1528
|
* @since 0.2.0
|
|
1451
1529
|
* @version 1.3.0
|
|
1452
1530
|
*
|
|
@@ -1485,7 +1563,7 @@ Model.setMethod(function createDocument(data, options) {
|
|
|
1485
1563
|
/**
|
|
1486
1564
|
* Create a document list
|
|
1487
1565
|
*
|
|
1488
|
-
* @author Jelle De Loecker
|
|
1566
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1489
1567
|
* @since 1.0.0
|
|
1490
1568
|
* @version 1.0.5
|
|
1491
1569
|
*
|
|
@@ -1523,7 +1601,7 @@ Model.setMethod(function createDocumentList(records, options) {
|
|
|
1523
1601
|
/**
|
|
1524
1602
|
* Insert record on the client side
|
|
1525
1603
|
*
|
|
1526
|
-
* @author Jelle De Loecker
|
|
1604
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1527
1605
|
* @since 1.0.0
|
|
1528
1606
|
* @version 1.0.0
|
|
1529
1607
|
*/
|
|
@@ -1540,13 +1618,13 @@ Model.setAfterMethod('ready', function _create(object, callback) {
|
|
|
1540
1618
|
/**
|
|
1541
1619
|
* Is the given action enabled on the server?
|
|
1542
1620
|
*
|
|
1543
|
-
* @author Jelle De Loecker
|
|
1621
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1544
1622
|
* @since 1.0.6
|
|
1545
1623
|
* @version 1.0.6
|
|
1546
1624
|
*
|
|
1547
|
-
* @param {
|
|
1625
|
+
* @param {string} action
|
|
1548
1626
|
*
|
|
1549
|
-
* @return {
|
|
1627
|
+
* @return {boolean}
|
|
1550
1628
|
*/
|
|
1551
1629
|
Model.setMethod(function hasServerAction(action) {
|
|
1552
1630
|
return this.constructor.hasServerAction(action);
|
|
@@ -1555,11 +1633,12 @@ Model.setMethod(function hasServerAction(action) {
|
|
|
1555
1633
|
/**
|
|
1556
1634
|
* Client-side model info
|
|
1557
1635
|
*
|
|
1558
|
-
* @type
|
|
1636
|
+
* @type {Object}
|
|
1559
1637
|
*/
|
|
1560
1638
|
Model.setProperty(function model_info() {
|
|
1561
1639
|
|
|
1562
|
-
let
|
|
1640
|
+
let class_name = this.constructor.name,
|
|
1641
|
+
model_name = this.constructor.model_name,
|
|
1563
1642
|
data;
|
|
1564
1643
|
|
|
1565
1644
|
if (Blast.isBrowser) {
|
|
@@ -1572,17 +1651,17 @@ Model.setProperty(function model_info() {
|
|
|
1572
1651
|
let config;
|
|
1573
1652
|
|
|
1574
1653
|
for (config of hawkejs.scene.exposed.model_info) {
|
|
1575
|
-
if (config.
|
|
1654
|
+
if (config.model_name === model_name) {
|
|
1576
1655
|
data = config;
|
|
1577
1656
|
break;
|
|
1578
1657
|
}
|
|
1579
1658
|
}
|
|
1580
1659
|
} else {
|
|
1581
1660
|
|
|
1582
|
-
let MainClass = Blast.Classes.Alchemy.Model
|
|
1661
|
+
let MainClass = Blast.Classes.Alchemy.Model.Model.get(model_name, false);
|
|
1583
1662
|
|
|
1584
1663
|
if (!MainClass) {
|
|
1585
|
-
throw new Error('Unable to find main class for "' +
|
|
1664
|
+
throw new Error('Unable to find main class for "' + model_name + '", unable to get client config!');
|
|
1586
1665
|
}
|
|
1587
1666
|
|
|
1588
1667
|
data = MainClass.getClientConfig();
|
|
@@ -1594,7 +1673,7 @@ Model.setProperty(function model_info() {
|
|
|
1594
1673
|
/**
|
|
1595
1674
|
* Schema
|
|
1596
1675
|
*
|
|
1597
|
-
* @type
|
|
1676
|
+
* @type {Object}
|
|
1598
1677
|
*/
|
|
1599
1678
|
Model.setProperty(function schema() {
|
|
1600
1679
|
return this.model_info.schema;
|
|
@@ -1603,7 +1682,7 @@ Model.setProperty(function schema() {
|
|
|
1603
1682
|
/**
|
|
1604
1683
|
* Associations
|
|
1605
1684
|
*
|
|
1606
|
-
* @type
|
|
1685
|
+
* @type {Object}
|
|
1607
1686
|
*/
|
|
1608
1687
|
Model.setProperty(function associations() {
|
|
1609
1688
|
return this.schema.associations;
|
|
@@ -1612,7 +1691,7 @@ Model.setProperty(function associations() {
|
|
|
1612
1691
|
/**
|
|
1613
1692
|
* Get a field instance from the schema
|
|
1614
1693
|
*
|
|
1615
|
-
* @author Jelle De Loecker
|
|
1694
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1616
1695
|
* @since 1.0.0
|
|
1617
1696
|
* @version 1.2.0
|
|
1618
1697
|
*
|
|
@@ -1645,7 +1724,7 @@ Hawkejs.Model = Model;
|
|
|
1645
1724
|
/**
|
|
1646
1725
|
* Save one record
|
|
1647
1726
|
*
|
|
1648
|
-
* @author Jelle De Loecker
|
|
1727
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1649
1728
|
* @since 0.0.1
|
|
1650
1729
|
* @version 1.3.20
|
|
1651
1730
|
*
|
|
@@ -1772,7 +1851,7 @@ Model.setMethod(function saveRecord(document, options, callback) {
|
|
|
1772
1851
|
/**
|
|
1773
1852
|
* Prepare some data by passing it through the schema
|
|
1774
1853
|
*
|
|
1775
|
-
* @author Jelle De Loecker
|
|
1854
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1776
1855
|
* @since 0.1.0
|
|
1777
1856
|
* @version 1.1.0
|
|
1778
1857
|
*
|
|
@@ -1792,7 +1871,7 @@ Model.setMethod(function compose(data, options) {
|
|
|
1792
1871
|
/**
|
|
1793
1872
|
* Create a record in the database
|
|
1794
1873
|
*
|
|
1795
|
-
* @author Jelle De Loecker
|
|
1874
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1796
1875
|
* @since 0.2.0
|
|
1797
1876
|
* @version 1.3.21
|
|
1798
1877
|
*
|
|
@@ -1854,7 +1933,7 @@ Model.setMethod(function createRecord(document, options, callback) {
|
|
|
1854
1933
|
/**
|
|
1855
1934
|
* Create a document used for saving
|
|
1856
1935
|
*
|
|
1857
|
-
* @author Jelle De Loecker
|
|
1936
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1858
1937
|
* @since 1.3.21
|
|
1859
1938
|
* @version 1.3.21
|
|
1860
1939
|
*
|
|
@@ -1877,7 +1956,7 @@ function createDocumentForSaving(model, original_input, data) {
|
|
|
1877
1956
|
/**
|
|
1878
1957
|
* Update a record in the database
|
|
1879
1958
|
*
|
|
1880
|
-
* @author Jelle De Loecker
|
|
1959
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1881
1960
|
* @since 0.2.0
|
|
1882
1961
|
* @version 1.3.21
|
|
1883
1962
|
*
|
|
@@ -1941,7 +2020,7 @@ Model.setMethod(function updateRecord(document, options, callback) {
|
|
|
1941
2020
|
/**
|
|
1942
2021
|
* Get records that need to be saved to the server
|
|
1943
2022
|
*
|
|
1944
|
-
* @author Jelle De Loecker
|
|
2023
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1945
2024
|
* @since 1.0.6
|
|
1946
2025
|
* @version 1.1.0
|
|
1947
2026
|
*/
|