Every line of 'mongodb find in array' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
12 function find(array, callback) { 13 for (var i = 0; i < array.length; i++) { 14 if (callback(array[i], i, array)) { 15 return array[i]; 16 } 17 } 18 }
113 function find(arr, callback) { 114 return arr[findIndex(arr, callback)]; 115 }
13 function find (array, id) { 14 if(!id) return 15 for (var k in array) { 16 if(array[k].id == id) return array[k] 17 } 18 }
51 async dbFind(db, id) { 52 return await conn.collection(db).findOne( 53 id 54 ); 55 }
152 findManyById(ids) { 153 return this.loader.loadMany(ids); 154 }
49 async findManyById(ids: string[]): Promise { 50 const collection = await this.collection; 51 const found = await collection.find({ _id: { $in: ids.map(id => new ObjectID(id)) } }).toArray(); 52 53 const results: DOC[] = []; 54 for (const result of found) { 55 results.push(await this.invokeEvents(POST_KEY, ['find', 'findMany'], this.toggleId(result, false))); 56 } 57 58 return results; 59 }
7 export function findObject (array, property, value) { 8 for (let i = 0; i < array.length; i++) { 9 if (array[i][property] === value) { 10 return array[i] 11 } 12 } 13 14 return null 15 }
10 export function findIndex<a>(array: A[], callback: (item: A) => boolean) { 11 const found = array.find(callback); 12 if (found) { 13 return array.indexOf(found); 14 } 15 return -1; 16 }</a>
90 function find(options, callback) { 91 mongoose.connection.db.collection(options.collection, function(err, collection) { 92 collection.find(options.query).skip(options.offset).limit(options.limit).toArray(callback); 93 }); 94 }
56 public async find(where: IWhere, language: string) { 57 const results = await this.i18nModel.find({ 58 id: { $in: where.ids }, 59 type: where.type, 60 language, 61 }).exec(); 62 63 return results.reduce((obj, item) => { 64 obj[item.id] = item.data; 65 return obj; 66 }, {}); 67 }