因此,基本上我已经写了一个程序,可以在Node中为MongoDB生成测试数据。
我悬赏这个问题以获得更多答案。要查看当前的解决方案,请向下滚动到下面的块引用!
为此,程序将读取模式文件并从中生成指定数量的测试数据。问题在于,这些数据最终可能变得非常大(考虑创建1M用户(具有所需的所有属性)和20M聊天消息(具有userFrom和userTo),并且必须将所有数据保留在RAM中以进行修改/转换/映射。然后将其保存到文件中。
该程序的工作方式如下:
referenceTo到具有match的随机对象referenceKey。string[]MongoDB插入语句中转换对象结构string[]在文件中。这是生成的测试数据的结构:
export interface IGeneratedCollection {
dbName: string, // Name of the database
collectionName: string, // Name of the collection
documents: IGeneratedDocument[] // One collection has many documents
}
export interface IGeneratedDocument {
documentFields: IGeneratedField [] // One document has many fields (which are recursive, because of nested documents)
}
export interface IGeneratedField {
fieldName: string, // …Run Code Online (Sandbox Code Playgroud) 我的文件夹结构如下所示(monorepo):
project
|
+--- /api
| |
| +--- /.offline-cache
| +--- /src
| | +--- index.js
| | +--- ...
| |
| +--- Dockerfile
| +--- package.json
| +--- yarn.lock
|
+--- /common
| |
| +--- /src
| | +--- index.js
| |
| +--- package.json
|
+--- /ui
| |
| +--- /.offline-cache
| +--- /src
| | +--- index.js
| | +--- ...
| |
| +--- Dockerfile
| +--- package.json
| +--- yarn.lock
| …Run Code Online (Sandbox Code Playgroud) 我想在另一个进程退出后运行一个进程。
例如,如果我正在运行一个节点 JS 文件并点击CTRL+ C,它应该关闭当前文件并从另一个 JS 文件运行另一个进程
类似的东西(伪代码):
process.on('exit', () => {
console.log("exiting")
}).then( //I am conscious it's wrong to put like that
//open another js file and run this process
);
Run Code Online (Sandbox Code Playgroud) 所以我通过 AngularFire 调用 firebase 函数,如下所示:
const response = await this.aFunctions.httpsCallable<void, ResponseType>('funcName')().toPromise();
Run Code Online (Sandbox Code Playgroud)
这在部署到 firebase(托管)时有效,但在本地环境中(使用ionic serve),它会引发此错误:
ERROR Error: Uncaught (in promise): FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).
FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad …Run Code Online (Sandbox Code Playgroud) firebase angularfire ionic-framework google-cloud-functions angular
有没有办法为 Angular 7 应用程序设置主题,以便您可以:
color, background-color, border-color, ...)使用一个类。我想做这样的事情:
<div color="primary">
</div>
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为该color属性仅适用于角度材料组件。
此外,我希望能够根据当前主题更改背景颜色、文本颜色等。(深色主题,浅色主题)
我认为展示我的意思的最好方法是使用一些代码示例:
type ObjType = {
[prop: string]: any
}
const x: ObjType = {
a: 1,
b: 'test'
}
type XType = typeof x;
Run Code Online (Sandbox Code Playgroud)
XType现在与 相同ObjType,但我希望它具有实际对象的类型。x但又不会失去对象必须匹配的选项ObjType。
有什么办法可以做到这一点吗?
我在尝试安装时总是遇到错误 go-pear.phar
这是错误,在遇到Enter问题后1-13, 'all' or Enter to continue:
1-13, 'all' or Enter to continue:
**ERROR**
Please, enter the php.exe path.
Run Code Online (Sandbox Code Playgroud)
我的环境路径中也安装了 PHP。我确实检查php --version并收到了消息
C:\xampp\php>php --version
PHP 7.2.31 (cli) (built: May 12 2020 10:26:32) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Run Code Online (Sandbox Code Playgroud)
所以我继续go-pear.phar使用命令进行安装。但我一直被困在上面的错误中。
C:\xampp\php>php go-pear.phar
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :
Below is …Run Code Online (Sandbox Code Playgroud) 我在此codepen中使用以下代码来尝试使用datetime-local今天的数据和时间填充输入元素。他们在本教程中提供的内容不起作用。我也尝试了这篇文章中的内容,但似乎也不起作用。如何将日期时间设置为今天的日期和时间到datetime-local输入元素中。谢谢。
HTML:
<input type="datetime-local" id="datetime" name="datetime">
Run Code Online (Sandbox Code Playgroud)
JS:
let today = new Date().toISOString();
document.getElementById('datetime').value = today;
console.log(today);
Run Code Online (Sandbox Code Playgroud) 我有以下 Dockerfile:
FROM node:latest
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json .
RUN npm install && npm i -g typescript
COPY . .
RUN tsc
CMD [ "node", "./dist/index.js" ]
Run Code Online (Sandbox Code Playgroud)
以及以下内容package.json:
FROM node:latest
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json .
RUN npm install && npm i -g typescript
COPY . .
RUN tsc
CMD [ "node", "./dist/index.js" ]
Run Code Online (Sandbox Code Playgroud)
当我尝试构建图像时,出现以下错误:
Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会发生这种情况?我已经@types/node …
我创建了一个JavaScript程序来将字符串转换为二进制。
Input: StackOverflow
Output: 1010011 1110100 1100001 1100011 1101011
1001111 1110110 1100101 1110010 1100110
1101100 1101111 1110111
Run Code Online (Sandbox Code Playgroud)
现在,我想将该二进制文件转换回如下所示的字符串。有什么可行的方法吗?
Input: 1010011 1110100 1100001 1100011 1101011
1001111 1110110 1100101 1110010 1100110
1101100 1101111 1110111
Output StackOverflow
Run Code Online (Sandbox Code Playgroud)
谢谢
javascript ×4
node.js ×4
angular ×2
docker ×2
typescript ×2
angularfire ×1
bigdata ×1
binary ×1
command ×1
css ×1
firebase ×1
monorepo ×1
node-modules ×1
performance ×1
php ×1
process ×1
sass ×1
test-data ×1
theming ×1
windows ×1
xampp ×1
yarnpkg ×1