So I tried taking the code and moving it out of the straight up server folder and included it in the api import process and I’m getting results now, but because my DB is very large, I’m getting a JS heap out of memory error. Do I need to create an index or something first with my data to help this process? Not sure how to do that, so I could use some guidance if that’s that solution.
imports/
---- api/
------ items/
--------server/
----------mapped-items.js
import { MappedCollection } from 'meteor/qualia:mapped-collection';
import { lasr } from 'meteor/qualia:lasr';
import { Items } from '../collection-items.js';
const mappedFields = [
'MFR_FULLNAME',
'MFR_CAT_NUM',
];
console.log(mappedFields);
const mappedItems = new MappedCollection({
collection: Items,
fields: mappedFields,
});
// console.log('mappedItems before promise');
// console.log(mappedItems);
// mappedItems.ready resolves when the map is fully initialized
Promise.await(mappedItems.ready);
// console.log('mappedItems after promise');
// console.log(mappedItems);
// mappedItems.map is a normal ES6 Map
const theItems = Array.from(mappedItems.map.values());
// console.log('theItems array');
// console.log(theItems);
// Here, we search for some items, but you can do anything with the map!
const results = lasr.search({
items: theItems,
query: 'RAYOVAC',
keys: ['MFR_FULLNAME'],
limit: 10,
});
console.log('### RESULST OF MAPPED COLLECTION ###');
console.log(results);