小编Ahm*_*afa的帖子

在将Sails.js与Waterline ORM结合使用时将Elasticsearch与PostgreSQL集成

我正在尝试将Elasticsearch与Sails.js集成,而我的数据库不是MongoDB:我使用PostgreSQL,所以这篇文章对您没有帮助。

我已经在Ubuntu盒子上安装了Elasticsearch,现在它已经成功运行。我也在我的Sails项目中安装了此软件包,但是无法在现有模型上创建索引。

如何在模型上定义索引,如何在模型内部使用Elasticsearch进行搜索?

我需要在模型中定义哪些钩子?

postgresql node.js elasticsearch sails.js

4
推荐指数
1
解决办法
1282
查看次数

我如何为 AsyncStorage 设置到期日期 - 反应原生

我正在使用 react native async storage 它运行良好,但在某些情况下,我必须为数据设置到期日期并刷新我检查过的存储

AsyncStorage 文档,但没有设置在特定时间后过期的选项。

唯一可用的选项是:-

AsyncStorage.removeItem 
Run Code Online (Sandbox Code Playgroud)

react-native asyncstorage

4
推荐指数
2
解决办法
7490
查看次数

如何在Typescript中添加扩展原型的文件

假设我想扩展String.prototype,所以我在ext/string.ts中有这个例子:

interface String {
    contains(sub: string): boolean;
}

String.prototype.contains = function (sub:string):boolean {
    if (sub === "") {
        return false;
    }
    return (this.indexOf(sub) !== -1);
};
Run Code Online (Sandbox Code Playgroud)

当我这样做import * as string from 'ext/string.ts'失败时出现此错误:

错误TS2306:文件'\ text/string.ts'不是模块

这是假设的行为,我没有写出口.但是我怎么告诉Typescript我想扩展String.prototype呢?

javascript typescript typescript1.8

2
推荐指数
1
解决办法
535
查看次数