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

Function _isManuallyPopulatedArray

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

Source from the content-addressed store, hash-verified

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