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

Function _isManuallyPopulatedArray

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

Source from the content-addressed store, hash-verified

1599 */
1600
1601function _isManuallyPopulatedArray(val, ref) {
1602 if (!Array.isArray(val)) {
1603 return false;
1604 }
1605 if (val.length === 0) {
1606 return false;
1607 }
1608
1609 for (const el of val) {
1610 if (!(el instanceof Document)) {
1611 return false;
1612 }
1613 const modelName = el.constructor.modelName;
1614 if (modelName == null) {
1615 return false;
1616 }
1617 if (el.constructor.modelName != ref && el.constructor.baseModelName != ref) {
1618 return false;
1619 }
1620 }
1621
1622 return true;
1623}
1624
1625/**
1626 * 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