mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Bugfix/Upserting same id with supabase (#2521)
fix upserting same id with supabase
This commit is contained in:
@@ -223,10 +223,17 @@ class SupabaseUpsertVectorStore extends SupabaseVectorStore {
|
||||
metadata: documents[idx].metadata
|
||||
}))
|
||||
|
||||
let idx = 0
|
||||
const { count } = await this.client.from(this.tableName).select('*', { count: 'exact', head: true })
|
||||
if (count) {
|
||||
idx = count
|
||||
}
|
||||
|
||||
let returnedIds: string[] = []
|
||||
for (let i = 0; i < rows.length; i += this.upsertBatchSize) {
|
||||
const chunk = rows.slice(i, i + this.upsertBatchSize).map((row, index) => {
|
||||
return { id: index, ...row }
|
||||
const chunk = rows.slice(i, i + this.upsertBatchSize).map((row) => {
|
||||
idx = idx += 1
|
||||
return { id: idx, ...row }
|
||||
})
|
||||
|
||||
const res = await this.client.from(this.tableName).upsert(chunk).select()
|
||||
@@ -237,6 +244,7 @@ class SupabaseUpsertVectorStore extends SupabaseVectorStore {
|
||||
returnedIds = returnedIds.concat(res.data.map((row) => row.id))
|
||||
}
|
||||
}
|
||||
|
||||
return returnedIds
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user