How to use the moleculer.isPromise function in moleculer

To help you get started, we’ve selected a few moleculer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github icebob / kantab / backend / mixins / database.js View on Github external
allFields.forEach(field => {
				// Skip if the field is not wanted
				if (wantedFields && wantedFields.indexOf(field.name) === -1) return;

				// Skip if hidden
				if (field.hidden === true) return;

				const value = _.get(doc, field.columnName || field.name);

				// Virtual or formatted field
				if (_.isFunction(field.get)) {
					const value = field.get.call(this, value, doc, ctx);
					if (isPromise(value))
						promises.push(value.then(v => setValue(res, field, v)));
					else
						setValue(res, field, value);

					return;
				}

				if (value !== undefined) {
					setValue(res, field, value);
				}
			});
github icebob / kantab / backend / mixins / database.js View on Github external
const callCustomFn = (field, fn, args) => {
				const value = fn.apply(this, args);
				if (isPromise(value))
					promises.push(value.then(v => setValue(field, v)));
				else
					setValue(field, value);
			};