当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript db.db类代码示例

本文整理汇总了TypeScript中eez-studio-shared/db.db的典型用法代码示例。如果您正苦于以下问题:TypeScript db类的具体用法?TypeScript db怎么用?TypeScript db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了db类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: insertSource

export function insertSource(instrumentName: string, instrumentExtensionId: string) {
    try {
        let result = db
            .prepare(
                `SELECT * FROM
                    "${notebookItemSourcesStore.storeName}"
                WHERE instrumentName = ? AND instrumentExtensionId = ?`
            )
            .get([instrumentName, instrumentExtensionId]);

        const existingSourceId = result && result.id;

        if (existingSourceId) {
            return existingSourceId;
        }

        const info = db
            .prepare(
                `INSERT INTO "notebook/sources" (instrumentName, instrumentExtensionId) VALUES(?, ?)`
            )
            .run([instrumentName, instrumentExtensionId]);

        return info.lastInsertRowid.toString();
    } catch (err) {
        console.error(err);
    }
    return null;
}
开发者ID:eez-open,项目名称:studio,代码行数:28,代码来源:store.ts

示例2: constructor

    constructor() {
        activityLogStore.watch(
            {
                createObject: (object: any) => {
                    if (object.type === "activity-log/session-start") {
                        runInAction(() => {
                            this.id = object.id;
                            this.message = object.message;
                        });
                    }
                },
                updateObject: (changes: any) => {
                    if (changes.id === this.id && changes.message !== undefined) {
                        try {
                            const message = JSON.parse(changes.message);
                            if (message.sessionCloseId) {
                                runInAction(() => {
                                    this.id = undefined;
                                    this.message = undefined;
                                });
                            } else {
                                runInAction(() => {
                                    this.message = changes.message;
                                });
                            }
                        } catch (err) {
                            console.error(err);
                        }
                    }
                },
                deleteObject: (object: any) => {
                    if (object.id === this.id) {
                        runInAction(() => {
                            this.id = undefined;
                            this.message = undefined;
                        });
                    }
                }
            },
            {
                skipInitialQuery: true
            }
        );

        const result = db
            .prepare(
                `SELECT
                    id
                FROM
                    activityLog
                WHERE
                    type = 'activity-log/session-start' AND
                    json_extract(message, '$.sessionCloseId') IS NULL
                ORDER BY date DESC
                LIMIT 1`
            )
            .get();

        this.id = result && result.id.toString();
    }
开发者ID:eez-open,项目名称:studio,代码行数:60,代码来源:activity-log.ts

示例3: loadData

export function loadData(store: IStore, id: string) {
    try {
        let result = db.prepare(`SELECT data FROM "${store.storeName}" WHERE id = ?`).get(id);
        return result && result.data;
    } catch (err) {
        console.error(err);
    }
    return undefined;
}
开发者ID:eez-open,项目名称:studio,代码行数:9,代码来源:activity-log.ts

示例4: getSource

export function getSource(sourceId: string): INotebookItemSource | null {
    try {
        let source = db
            .prepare(`SELECT * FROM "${notebookItemSourcesStore.storeName}" WHERE id = ? `)
            .get([sourceId]);

        return source;
    } catch (err) {
        console.error(err);
    }
    return null;
}
开发者ID:eez-open,项目名称:studio,代码行数:12,代码来源:store.ts

示例5: deleteGroupInShortcuts

export function deleteGroupInShortcuts(groupName: string) {
    db.prepare(`DELETE FROM "${store.storeName}" WHERE groupName = ?`).run(groupName);

    let changedShortcuts = values(shortcuts)
        .filter(shortcut => shortcut.groupName === groupName)
        .map(shortcut => ({ id: shortcut.id }));

    sendMessage(store.notifySource, {
        op: "delete",
        object: changedShortcuts
    });
}
开发者ID:eez-open,项目名称:studio,代码行数:12,代码来源:shortcuts-store.ts

示例6: async

export default service<Params, Result>("db-services/query", async (inputParams: Params) => {
    try {
        const rows = db.prepare(inputParams.query).all(...inputParams.args);
        return {
            err: null,
            rows
        };
    } catch (err) {
        return {
            err,
            rows: []
        };
    }
});
开发者ID:eez-open,项目名称:studio,代码行数:14,代码来源:query.ts

示例7: insertSourceFromInstrumentId

export function insertSourceFromInstrumentId(instrumentId: string) {
    try {
        let result = db
            .prepare(`SELECT * FROM "${instrumentsStore.storeName}" WHERE id = ?`)
            .get([instrumentId]);

        if (result && result.id) {
            return insertSource(
                getInstrumentDescription(result.instrumentExtensionId, result.label, result.idn),
                result.instrumentExtensionId
            );
        }
    } catch (err) {
        console.error(err);
    }
    return null;
}
开发者ID:eez-open,项目名称:studio,代码行数:17,代码来源:store.ts

示例8: async

export default service<void, void>("db-services/vacuum", async () => {
    db.exec("VACUUM");
});
开发者ID:eez-open,项目名称:studio,代码行数:3,代码来源:vacuum.ts


注:本文中的eez-studio-shared/db.db类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。