FIX: Transaction Bugs
This commit is contained in:
@@ -47,6 +47,7 @@ const createTransaction = async (data) => {
|
||||
description: data.description,
|
||||
userId: data.userId,
|
||||
belongingId: data.belongingId,
|
||||
userName: data.userName,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -198,6 +199,7 @@ const indexAllTransactions = async () => {
|
||||
const transactions = await Transaction.find({}, null, null)
|
||||
.skip((i - 1) * batchSize)
|
||||
.limit(batchSize)
|
||||
.populate('belongingId')
|
||||
|
||||
let documents = []
|
||||
|
||||
@@ -206,10 +208,13 @@ const indexAllTransactions = async () => {
|
||||
_id: transaction._id,
|
||||
type: transaction.type,
|
||||
status: transaction.status,
|
||||
source: transaction.source,
|
||||
source: transaction.source || '',
|
||||
value: transaction.value,
|
||||
description: transaction.description,
|
||||
createdAt: Math.floor(new Date(transaction.createdAt).getTime() / 1000), // Store as timestamp in seconds
|
||||
belongingName: transaction.belongingId.name,
|
||||
belongingId: transaction.belongingId._id,
|
||||
userName: transaction.userName || '',
|
||||
}
|
||||
|
||||
documents.push(data)
|
||||
@@ -233,6 +238,9 @@ const getTypeSenseSchema = () => {
|
||||
{ name: 'value', type: 'int64', facet: false },
|
||||
{ name: 'description', type: 'string', facet: false, infix: true },
|
||||
{ name: 'createdAt', type: 'int64', facet: false },
|
||||
{ name: 'belongingName', type: 'string', facet: false, infix: true },
|
||||
{ name: 'belongingId', type: 'string', facet: false, infix: true },
|
||||
{ name: 'userName', type: 'string', facet: false, infix: true },
|
||||
],
|
||||
default_sorting_field: 'createdAt',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user