MCPcopy Create free account
hub / github.com/dresende/node-orm2 / autoFetchInstance

Function autoFetchInstance

lib/Associations/Many.js:491–512  ·  view source on GitHub ↗
(Instance, association, opts, cb)

Source from the content-addressed store, hash-verified

489}
490
491function autoFetchInstance(Instance, association, opts, cb) {
492 if (!Instance.saved()) {
493 return cb();
494 }
495
496 if (!opts.hasOwnProperty("autoFetchLimit") || typeof opts.autoFetchLimit == "undefined") {
497 opts.autoFetchLimit = association.autoFetchLimit;
498 }
499
500 if (opts.autoFetchLimit === 0 || (!opts.autoFetch && !association.autoFetch)) {
501 return cb();
502 }
503
504 Instance[association.getAccessor]({}, { autoFetchLimit: opts.autoFetchLimit - 1 }, function (err, Assoc) {
505 if (!err) {
506 // Set this way to prevent setting 'changed' status
507 Instance.__opts.associations[association.name].value = Assoc;
508 }
509
510 return cb();
511 });
512}
513
514function ucfirst(text) {
515 return text[0].toUpperCase() + text.substr(1).replace(/_([a-z])/, function (m, l) {

Callers 1

Many.jsFile · 0.70

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected