MCPcopy Index your code
hub / github.com/parse-community/parse-server / contains

Function contains

src/LiveQuery/QueryTools.js:140–164  ·  view source on GitHub ↗

* contains -- Determines if an object is contained in a list with special handling for Parse pointers.

(haystack: Array, needle: any)

Source from the content-addressed store, hash-verified

138 * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
139 */
140function contains(haystack: Array, needle: any): boolean {
141 if (needle && needle.__type && needle.__type === 'Pointer') {
142 for (const i in haystack) {
143 const ptr = haystack[i];
144 if (typeof ptr === 'string' && ptr === needle.objectId) {
145 return true;
146 }
147 if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
148 return true;
149 }
150 }
151
152 return false;
153 }
154
155 if (Array.isArray(needle)) {
156 for (const need of needle) {
157 if (contains(haystack, need)) {
158 return true;
159 }
160 }
161 }
162
163 return haystack.indexOf(needle) > -1;
164}
165/**
166 * matchesQuery -- Determines if an object would be returned by a Parse Query
167 * It's a lightweight, where-clause only implementation of a full query engine.

Callers 1

matchesKeyConstraintsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected