-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from anran758/develop
Enhance io operations: support for bulk operations and improved type handling
- Loading branch information
Showing
36 changed files
with
4,111 additions
and
10,162 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createFaas } from '@mincloudx/faas'; | ||
import io from '@/io'; | ||
|
||
export default createFaas(async function main() { | ||
const query = io.getQuery({ | ||
description: 'This is description.', | ||
}); | ||
const count = await io.product.count(query); | ||
|
||
console.log('count: ', count); | ||
|
||
return { count }; | ||
}); |
37 changes: 37 additions & 0 deletions
37
apps/faas-demo/src/function/test/testOperationCreateMany.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createFaas } from '@mincloudx/faas'; | ||
import io from '@/io'; | ||
|
||
import { getCurrentDate } from '@/utils'; | ||
|
||
function generatorMockData() { | ||
const rawData = { | ||
name: `新书本-${getCurrentDate()}`, | ||
cover: | ||
'https://cloud-minapp-47549.cloud.ifanrusercontent.com/1rmlh9degSiaF4ua.jpg', | ||
description: 'testOperationCreateMany create.', | ||
}; | ||
|
||
return Array(6) | ||
.fill(0) | ||
.map((_, i) => { | ||
return { | ||
...rawData, | ||
name: `${rawData.name}_${i}`, | ||
}; | ||
}); | ||
} | ||
export default createFaas(async function main() { | ||
const list = generatorMockData(); | ||
|
||
const { | ||
operation_result: result, | ||
succeed, | ||
total_count, | ||
} = await io.product.createMany(list); | ||
|
||
console.log('result:', result); | ||
console.log('succeed: ', succeed); | ||
console.log('total: ', total_count); | ||
|
||
return result; | ||
}); |
17 changes: 17 additions & 0 deletions
17
apps/faas-demo/src/function/test/testOperationDeleteMany.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createFaas } from '@mincloudx/faas'; | ||
import io from '@/io'; | ||
|
||
export default createFaas(async function main() { | ||
const result = await io.product.deleteMany(io.query, { | ||
limit: 2, | ||
}); | ||
console.log( | ||
'result: ', | ||
result.succeed, | ||
result.offset, | ||
result.limit, | ||
result.next, | ||
); | ||
|
||
return result; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createFaas } from '@mincloudx/faas'; | ||
import io from '@/io'; | ||
|
||
export default createFaas(async function main() { | ||
const query = io.getQuery({ | ||
description: 'This is description.', | ||
}); | ||
const result = await io.product.find(query, { | ||
select: ['id', 'name', 'description'], | ||
plain: true, | ||
}); | ||
|
||
return result; | ||
}); |
17 changes: 17 additions & 0 deletions
17
apps/faas-demo/src/function/test/testOperationUpdateMany.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createFaas } from '@mincloudx/faas'; | ||
import io from '@/io'; | ||
|
||
export default createFaas(async function main() { | ||
const list = await io.product.updateMany({ | ||
query: io.getQuery({ | ||
created_at: 1711691446, | ||
}), | ||
data: { | ||
description: `update date: ${new Date()}`, | ||
}, | ||
}); | ||
|
||
console.log('result:', list); | ||
|
||
return list; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { createIo } from '@mincloudx/io'; | ||
|
||
export default createIo({ | ||
tables: ['channel'], | ||
tables: ['channel', 'product'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getCurrentDate() { | ||
const now = new Date(); | ||
|
||
// 分别获取日期和时间字符串 | ||
const dateString = now | ||
.toLocaleDateString('zh-CN', { | ||
year: 'numeric', | ||
month: '2-digit', | ||
day: '2-digit', | ||
}) | ||
.replace(/\//g, '-'); | ||
|
||
const timeString = now.toLocaleTimeString('zh-CN', { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
hour12: false, // 使用24小时制 | ||
}); | ||
|
||
return `${dateString} ${timeString}`; | ||
} |
Oops, something went wrong.