modelNames.forEach((modelName) => { const { fields, references, options } = schema[modelName]; const safeReferences = references.map((reference) => ({ ...reference, ref: getModelNameFromTableName(reference.ref), })); writeModel(modelName, fields, safeReferences, options); });
constructor(...args) { super(...args); // JM: It bugs me this is duplicated in the implementation but initialisation order makes it hard to avoid const [refListKey, refFieldPath] = this.config.ref.split('.'); this.refListKey = refListKey; this.refFieldPath = refFieldPath; this.isRelationship = true; }
function commitDetachRef(current) { var currentRef = current.ref; if (currentRef !== null) { if (typeof currentRef === 'function') { currentRef(null); } else { currentRef.current = null; } } }
function warnIfStringRefCannotBeAutoConverted(config) { { if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { var componentName = getComponentName(ReactCurrentOwner.current.type); if (!didWarnAboutStringRefs[componentName]) { error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref); didWarnAboutStringRefs[componentName] = true; } } } }
// Add virtual key to provide populate and reverse populate _.forEach( _.pickBy(definition.loadedModel, ({ type }) => type === 'virtual'), (value, key) => { schema.virtual(key, { ref: value.ref, localField: '_id', foreignField: value.via, justOne: value.justOne || false, }); } );
(function() { const broker = new ServiceBroker({ logger: false }); broker.loadService(__dirname + "/../user.service"); broker.start(); bench.ref("Without custom middlewares", done => { return broker.call("users.find").then(done); }); })();
(function() { const broker = createBroker(); bench1.ref("broker.call (normal)", done => { return broker.call("users.empty").then(done); }); bench1.add("broker.call (with params)", done => { return broker.call("math.add", { a: 4, b: 2 }).then(done); }); })();
const refToStrapiRef = obj => { const ref = obj.ref; let plainData = ref && typeof ref.toJSON === 'function' ? ref.toJSON() : ref; if (typeof plainData !== 'object') return ref; return { __contentType: obj.kind, ...ref, }; }
(function() { const broker = createBroker(); bench6.ref("No tracing", done => { return broker.call("users.empty").then(done); }); })();
(function() { let broker = createBroker( { trackContext: true }); bench6.ref("broker.call (without tracking)", done => { return broker.call("math.add", { a: 4, b: 2 }, { trackContext: false }).then(done); }); bench6.add("broker.call (with tracking)", done => { return broker.call("math.add", { a: 4, b: 2 }, { trackContext: true }).then(done); }); })();
const refToStrapiRef = obj => { const ref = obj.ref; let plainData = ref && typeof ref.toJSON === 'function' ? ref.toJSON() : ref; if (typeof plainData !== 'object') return ref; return { __contentType: obj.kind, ...ref, }; }
constructor(...args) { super(...args); // JM: It bugs me this is duplicated in the implementation but initialisation order makes it hard to avoid const [refListKey, refFieldPath] = this.config.ref.split('.'); this.refListKey = refListKey; this.refFieldPath = refFieldPath; this.isRelationship = true; }
(function() { const broker = createBroker(); bench2.ref("Call without middlewares", done => { return broker.call("users.empty").then(done); }); })();
(function() { const broker = createBroker({ internalMiddlewares: false }); bench2.ref("Call without internal middlewares", done => { return broker.call("users.empty").then(done); }); })();
(function() { const broker = createBroker(); bench3.ref("No metrics", done => { return broker.call("users.empty").then(done); }); })();