diff --git a/deno.json b/deno.json index 46be349..6f63ca6 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@andyburke/fsdb", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "exports": { ".": "./fsdb.ts", diff --git a/indexers/symlinks.ts b/indexers/symlinks.ts index 813cdf3..5554095 100644 --- a/indexers/symlinks.ts +++ b/indexers/symlinks.ts @@ -170,11 +170,12 @@ export class FSDB_INDEXER_SYMLINKS implements FSDB_INDEXER { const results: string[] = []; const values: string[] = this.get_values_to_index(item); - if (values.length === 0) { - return results; - } for (const value of values) { + if (typeof value === 'undefined') { + continue; + } + const organized_paths: string[] = this.config.organize(value); if (organized_paths.length === 0) { continue; diff --git a/tests/04_indexing_sanity_checks.test.ts b/tests/04_indexing_sanity_checks.test.ts index ab5acb0..ad79e3e 100644 --- a/tests/04_indexing_sanity_checks.test.ts +++ b/tests/04_indexing_sanity_checks.test.ts @@ -44,6 +44,12 @@ Deno.test({ organize: by_character, get_values_to_index: (item: ITEM) => item.value.split(/\W/).filter((word) => word.length > 3), to_many: true + }), + by_possibly_undefined: new FSDB_INDEXER_SYMLINKS({ + name: 'by_possibly_undefined', + organize: by_character, + get_values_to_index: (item: ITEM) => item.email.indexOf('.com') > 0 ? [item.email] : [], + to_many: true }) } }); @@ -51,7 +57,7 @@ Deno.test({ asserts.assert(item_collection); const items: ITEM[] = []; - for (let i = 0; i < 10; ++i) { + for (let i = 0; i < 50; ++i) { const item = { id: lurid(), email: random_email_address(), @@ -88,21 +94,21 @@ Deno.test({ } // leave one item behind so the whole db for this test doesn't get cleaned up so I can hand-review it - for (const item of items.slice(1)) { - await item_collection.delete(item); + // for (const item of items.slice(1)) { + // await item_collection.delete(item); - const fetched_by_email: ITEM[] = (await item_collection.find({ email: item.email })).map((entry) => entry.load()); - asserts.assertFalse(fetched_by_email.find((email_item) => email_item.id === item.id)); + // const fetched_by_email: ITEM[] = (await item_collection.find({ email: item.email })).map((entry) => entry.load()); + // asserts.assertFalse(fetched_by_email.find((email_item) => email_item.id === item.id)); - const fetched_by_phone: ITEM[] = (await item_collection.find({ phone: item.phone })).map((entry) => entry.load()); - asserts.assertFalse(fetched_by_phone.find((phone_item) => phone_item.id === item.id)); + // const fetched_by_phone: ITEM[] = (await item_collection.find({ phone: item.phone })).map((entry) => entry.load()); + // asserts.assertFalse(fetched_by_phone.find((phone_item) => phone_item.id === item.id)); - const words_in_value: string[] = item.value.split(/\W/).filter((word) => word.length > 3); - const random_word_in_value: string = words_in_value[Math.floor(Math.random() * words_in_value.length)]; - const fetched_by_word_in_value: ITEM[] = (await item_collection.find({ by_character_test: random_word_in_value })).map(( - entry - ) => entry.load()); - asserts.assertFalse(fetched_by_word_in_value.find((word_in_value_item) => word_in_value_item.id === item.id)); - } + // const words_in_value: string[] = item.value.split(/\W/).filter((word) => word.length > 3); + // const random_word_in_value: string = words_in_value[Math.floor(Math.random() * words_in_value.length)]; + // const fetched_by_word_in_value: ITEM[] = (await item_collection.find({ by_character_test: random_word_in_value })).map(( + // entry + // ) => entry.load()); + // asserts.assertFalse(fetched_by_word_in_value.find((word_in_value_item) => word_in_value_item.id === item.id)); + // } } });