File tree Expand file tree Collapse file tree 4 files changed +37
-11
lines changed Expand file tree Collapse file tree 4 files changed +37
-11
lines changed Original file line number Diff line number Diff line change 1
1
import process from 'node:process'
2
2
import { log } from '@stacksjs/logging'
3
- import { createStripeProduct } from '@stacksjs/payments '
3
+ import { importModelDocuments } from '@stacksjs/search-engine '
4
4
5
- const result = await createStripeProduct ( )
5
+ const result = await importModelDocuments ( )
6
6
7
7
if ( result ?. isErr ( ) ) {
8
8
console . error ( result . error )
Original file line number Diff line number Diff line change
1
+ import { getTableName } from '@stacksjs/orm'
2
+ import { path } from '@stacksjs/path'
3
+ import { useSearchEngine } from '@stacksjs/search-engine'
4
+ import { globSync } from '@stacksjs/storage'
5
+
6
+ async function importModelDocuments ( ) {
7
+ const userModelFiles = globSync ( [ path . userModelsPath ( '*.ts' ) ] , { absolute : true } )
8
+ const { addDocument } = useSearchEngine ( )
9
+
10
+ for ( const userModel of userModelFiles ) {
11
+ const modelInstance = ( await import ( userModel ) ) . default
12
+
13
+ const tableName = getTableName ( modelInstance , userModel )
14
+
15
+ const documents = modelInstance . all ( )
16
+
17
+ for ( const document of documents ) {
18
+ await addDocument ( tableName , document )
19
+ }
20
+ }
21
+
22
+
23
+
24
+ }
Original file line number Diff line number Diff line change @@ -97,8 +97,7 @@ async function listAllIndexes(): Promise<IndexesResults<Index[]>> {
97
97
98
98
// return filters
99
99
// }
100
-
101
- export default {
100
+ const meilisearch : SearchEngineDriver = {
102
101
client,
103
102
// search,
104
103
createIndex,
@@ -113,4 +112,7 @@ export default {
113
112
deleteDocument,
114
113
deleteDocuments,
115
114
getDocument,
116
- } satisfies SearchEngineDriver
115
+ }
116
+
117
+
118
+ export default meilisearch
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ import type { UiEngine } from '@stacksjs/ui'
2
2
import { useStorage } from '@stacksjs/utils'
3
3
import { computed , type ComputedRef , type Ref , ref } from 'vue'
4
4
5
- // import { client as meilisearch } from './drivers/meilisearch'
5
+ import meilisearch from './drivers/meilisearch'
6
+
6
7
import { determineState } from './helpers'
8
+ import type { SearchEngineDriver } from '@stacksjs/types'
7
9
8
10
// import type { Ref } from '@stacksjs/types'
9
11
@@ -32,13 +34,11 @@ export const setTotalHits: ComputedRef = computed(() => table.setTotalHits)
32
34
export const sort : ComputedRef = computed ( ( ) => table . sort )
33
35
export const sorts : ComputedRef = computed ( ( ) => table . sorts )
34
36
35
- function client ( ) : string {
36
- // if (searchEngine.driver === 'meilisearch')
37
- // return meilisearch
38
- return 'wip-search-me'
37
+ function client ( ) : any {
38
+ return meilisearch
39
39
}
40
40
41
- export function useSearchEngine ( ) : string {
41
+ export function useSearchEngine ( ) : SearchEngineDriver {
42
42
return client ( )
43
43
}
44
44
You can’t perform that action at this time.
0 commit comments