mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +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
|
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[] = []
|
let returnedIds: string[] = []
|
||||||
for (let i = 0; i < rows.length; i += this.upsertBatchSize) {
|
for (let i = 0; i < rows.length; i += this.upsertBatchSize) {
|
||||||
const chunk = rows.slice(i, i + this.upsertBatchSize).map((row, index) => {
|
const chunk = rows.slice(i, i + this.upsertBatchSize).map((row) => {
|
||||||
return { id: index, ...row }
|
idx = idx += 1
|
||||||
|
return { id: idx, ...row }
|
||||||
})
|
})
|
||||||
|
|
||||||
const res = await this.client.from(this.tableName).upsert(chunk).select()
|
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))
|
returnedIds = returnedIds.concat(res.data.map((row) => row.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnedIds
|
return returnedIds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user