New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

siyuan_api_cache_lib

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

siyuan_api_cache_lib - npm Package Compare versions

Comparing version

to
1.0.2

7

dist/siyuan-api/attr.d.ts

@@ -21,3 +21,3 @@ import type { attrRow } from "./type";

* 查询块属性
*
* 在查询自身时该怎么 cache ,如果直接 cache 会导致无限增长
* tips: 可以使用 {@link htmlDecode util.htmlDecode} 对 {@link attrRow} 的 value 进行解码

@@ -33,1 +33,6 @@ */

}
/** 查询单个属性 */
export declare function getBlockAttr(id: string, name: string): Promise<attrRow | undefined>;
export declare namespace getBlockAttr {
let noCache: boolean;
}

@@ -18,7 +18,8 @@ import { htmlDecode } from "../util/index";

* 查询块属性
*
* 在查询自身时该怎么 cache ,如果直接 cache 会导致无限增长
* tips: 可以使用 {@link htmlDecode util.htmlDecode} 对 {@link attrRow} 的 value 进行解码
*/
export async function getBlockAttrs(id) {
return await sqlQuery(`SELECT * FROM "attributes" WHERE block_id='${id}'`);
const r = sqlQuery(`SELECT * FROM "attributes" WHERE block_id='${id}'`);
return r;
}

@@ -28,1 +29,9 @@ (function (getBlockAttrs) {

})(getBlockAttrs || (getBlockAttrs = {}));
/** 查询单个属性 */
export async function getBlockAttr(id, name) {
const attrs = (await getBlockAttrs(id)).data;
return attrs.find((el) => el.name === name);
}
(function (getBlockAttr) {
getBlockAttr.noCache = false;
})(getBlockAttr || (getBlockAttr = {}));

2

package.json
{
"name": "siyuan_api_cache_lib",
"version": "1.0.1",
"version": "1.0.2",
"description": "为思源挂件块提供 api 访问的工具库,同时具有缓存 api 调用结果到块属性上以及在非思源笔记环境下使用缓存结果的功能",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -25,2 +25,8 @@ # siyuan_api_cache_lib

## 注意事项
请确保使用了缓存的接口不会一直增长数据,否则容易出现如下问题
![](./doc/QQ截图20210805202648.jpg)
## 思源挂件块开发实践

@@ -27,0 +33,0 @@