fix(doc): Refactor searchable fields API and improve collection registration.

This commit is contained in:
2025-04-21 16:35:29 +00:00
parent eef758cabb
commit d0e769622e
7 changed files with 53 additions and 87 deletions

View File

@ -1,7 +1,7 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartmongo from '@push.rocks/smartmongo';
import * as smartdata from '../ts/index.js';
import { searchable, getSearchableFields } from '../ts/classes.doc.js';
import { searchable } from '../ts/classes.doc.js';
import { smartunique } from '../ts/plugins.js';
// Set up database connection

View File

@ -4,7 +4,7 @@ import { smartunique } from '../ts/plugins.js';
// Import the smartdata library
import * as smartdata from '../ts/index.js';
import { searchable, getSearchableFields } from '../ts/classes.doc.js';
import { searchable } from '../ts/classes.doc.js';
// Set up database connection
let smartmongoInstance: smartmongo.SmartMongo;
@ -72,7 +72,7 @@ tap.test('should create test products with searchable fields', async () => {
tap.test('should retrieve searchable fields for a class', async () => {
// Use the getSearchableFields function to verify our searchable fields
const searchableFields = getSearchableFields('Product');
const searchableFields = Product.getSearchableFields();
console.log('Searchable fields:', searchableFields);
expect(searchableFields.length).toEqual(3);

View File

@ -64,7 +64,11 @@ tap.test('should watch a collection', async (toolsArg) => {
// close the database connection
// =======================================
tap.test('close', async () => {
await testDb.mongoDb.dropDatabase();
try {
await testDb.mongoDb.dropDatabase();
} catch (err) {
console.warn('dropDatabase error ignored in cleanup:', err.message || err);
}
await testDb.close();
if (smartmongoInstance) {
await smartmongoInstance.stop();