MCPcopy Create free account
hub / github.com/Automattic/mongoose / _isManuallyPopulatedArray

Function _isManuallyPopulatedArray

lib/document.js:1507–1529  ·  view source on GitHub ↗
(val, ref)

Source from the content-addressed store, hash-verified

1505 */
1506
1507function _isManuallyPopulatedArray(val, ref) {
1508 if (!Array.isArray(val)) {
1509 return false;
1510 }
1511 if (val.length === 0) {
1512 return false;
1513 }
1514
1515 for (const el of val) {
1516 if (!(el instanceof Document)) {
1517 return false;
1518 }
1519 const modelName = el.constructor.modelName;
1520 if (modelName == null) {
1521 return false;
1522 }
1523 if (el.constructor.modelName != ref && el.constructor.baseModelName != ref) {
1524 return false;
1525 }
1526 }
1527
1528 return true;
1529}
1530
1531/**
1532 * Sets the value of a path, or many paths.

Callers 1

document.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected