Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
7c5bc957
Commit
7c5bc957
authored
Aug 03, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize sqlite middleware and ready for deck page
parent
9ef609d1
Pipeline
#22872
passed with stages
in 17 minutes and 5 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
src/middleware/sqlite.ts
src/middleware/sqlite.ts
+17
-6
No files found.
src/middleware/sqlite.ts
View file @
7c5bc957
...
@@ -29,8 +29,9 @@ export interface sqliteAction {
...
@@ -29,8 +29,9 @@ export interface sqliteAction {
};
};
// 需要读取卡牌数据的ID
// 需要读取卡牌数据的ID
payload
?:
{
payload
?:
{
id
?:
number
;
id
?:
number
;
// 卡牌ID
query
?:
string
;
query
?:
string
;
// 用于全文检索的query
type
?:
number
;
// 通过`type`过滤
};
};
}
}
...
@@ -85,7 +86,9 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
...
@@ -85,7 +86,9 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
}
}
case
sqliteCmd
.
FTS
:
{
case
sqliteCmd
.
FTS
:
{
if
(
YGODB
&&
action
.
payload
&&
action
.
payload
.
query
)
{
if
(
YGODB
&&
action
.
payload
&&
action
.
payload
.
query
)
{
// TODO: 这里应该可以优化为联表查询
const
query
=
action
.
payload
.
query
;
const
query
=
action
.
payload
.
query
;
const
type
=
action
.
payload
.
type
;
const
ftsTexts
:
CardText
[]
=
[];
const
ftsTexts
:
CardText
[]
=
[];
const
ftsMetas
:
CardMeta
[]
=
[];
const
ftsMetas
:
CardMeta
[]
=
[];
...
@@ -101,10 +104,18 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
...
@@ -101,10 +104,18 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
for
(
const
text
of
ftsTexts
)
{
for
(
const
text
of
ftsTexts
)
{
const
id
=
text
.
id
;
const
id
=
text
.
id
;
if
(
id
)
{
if
(
id
&&
type
!==
undefined
)
{
const
dataStmt
=
YGODB
.
prepare
(
const
sql
=
"
SELECT * FROM datas WHERE ID = $id AND type = $type
"
;
"
SELECT * FROM datas WHERE ID = $id
"
const
dataStmt
=
YGODB
.
prepare
(
sql
);
);
const
data
:
CardData
=
dataStmt
.
getAsObject
({
$id
:
id
,
$type
:
type
,
});
ftsMetas
.
push
({
id
,
data
,
text
});
}
else
if
(
id
)
{
const
sql
=
"
SELECT * FROM datas WHERE ID = $id
"
;
const
dataStmt
=
YGODB
.
prepare
(
sql
);
const
data
:
CardData
=
dataStmt
.
getAsObject
({
$id
:
id
});
const
data
:
CardData
=
dataStmt
.
getAsObject
({
$id
:
id
});
ftsMetas
.
push
({
id
,
data
,
text
});
ftsMetas
.
push
({
id
,
data
,
text
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment