我正在学习 NestJS,这是我的简单服务:
import { Injectable } from '@nestjs/common';
const userMock = [{ account: 'dung', password: '12345678' }];
@Injectable()
export class UserService {
getUser() {
return userMock
}
}
Run Code Online (Sandbox Code Playgroud)
我不太了解@Injectable
NestJS。一些教程告诉@Injectable
我们@Controller
知道这是一个安装并且可以将其用作依赖项注入。但当我删除它时,它仍然有效。
请举例说明有@Injectable
和没有的区别@Injectable
我必须通过谷歌帐户实现登录。
我想要一些建议。
我在谷歌控制台中创建了项目。添加范围用户 info.profile
我正在学习互联网上的课程说明,但我仍然无法获取用户信息(电子邮件、姓名、年龄...)。
步:
{
"azp": "155122683461-51hq2n932svo4ajbt98ic0q67m4tuj5o.apps.googleusercontent.com",
"aud": "155122683461-51hq2n932svo4ajbt98ic0q67m4tuj5o.apps.googleusercontent.com",
"sub": "108865940357700877124",
"scope": "https://www.googleapis.com/auth/userinfo.profile",
"exp": "1554094721",
"expires_in": "3326",
"access_type": "offline"
}
Run Code Online (Sandbox Code Playgroud)
你们可以举个例子吗:(
谢谢
我想运行 lint 检查所有没有 node_modules 的文件 *.js
这里是我的命令:"lint": "eslint **/*.js",
,我的文件夹结构如下所示:app > module_name > module.js
但在应用程序文件夹中仍然有一些常见的文件,例如helpers.js
server.js
,我也想检查它们。
在 .eslint 配置中,我添加"ignorePatterns": "node_modules"
并尝试添加文件 .eslintignore 并添加,node_modules
但它不起作用。
当我运行时npm run lint
总是抛出错误:
Oops! Something went wrong! :(
ESLint: 7.32.0
You are linting "node_modules/bignumber.js", but all of the files matching the glob pattern "node_modules/bignumber.js" are ignored.
If you don't want to lint these files, remove the pattern "node_modules/bignumber.js" from the list of arguments passed to ESLint.
If you …
Run Code Online (Sandbox Code Playgroud) 我有两个 Mongo 模式:
用户:
{
_id: ObjectId,
name: String,
country: ObjectId // Reference to schema Country
}
Run Code Online (Sandbox Code Playgroud)
国家:
{
_id: ObjectId,
name: String
}
Run Code Online (Sandbox Code Playgroud)
我想获取所有国家/地区名称为“VietNam”的用户。
对于这种情况,我可以使用哪种查询(仅针对用户模式)?
我希望它看起来像这样的 SQL 查询:
SELECT *
FROM User
JOIN Country
ON User.country = Country._id
WHERE Country.name = 'VietNam'
Run Code Online (Sandbox Code Playgroud) 这是样本数据
[{ date: '2020-05-21T14:02:00.0123 }, { date: '2020-05-22T14:02:00.0123 }, { date: '2020-05-23T14:02:00.0123 }]
Run Code Online (Sandbox Code Playgroud)
我想过滤 5 月 22 日或更早的记录,这是我的预期:
[{ date: '2020-05-21T14:02:00.0123 }, { date: '2020-05-22T14:02:00.0123 }]
Run Code Online (Sandbox Code Playgroud)
我尝试过这个查询:
{ date: { $lte: new Date('2020-05-22') }}
Run Code Online (Sandbox Code Playgroud)
但它仅返回 5 月 22 日之前的数据。我认为问题是{ date: { $lte: new Date('2020-05-22') }}
data.date lte 2020-05-22T00:00:00.000
我如何排除时间?
我有一个历史记录集合,并且想要基于该集合创建导出数据库
[{
_id: "...",
value: 10,
at: ISODate("2021-24-06T00:01:02.023")
}, {
_id: ...,
value: 13,
at: ISODate("2021-24-06T00:04:11.211")
}, {
_id: ...,
value: 12,
at: ISODate("2021-24-06T09:11:31.182")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-07T01:33:31.723")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-15T09:32:44.983")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-16T10:43:22.083")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-16T14:43:22.083")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-17T04:25:12.021")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-18T20:13:22.083")
}, {
_id: ...,
value: 40,
at: ISODate("2021-24-19T18:41:22.083") …
Run Code Online (Sandbox Code Playgroud) [
{"name": "Card 1"},
{"name": "Card 2"},
{"name": "Card 10"}
]
Run Code Online (Sandbox Code Playgroud)
MongoDb结果的排序依据{ "name": 1 }
是
[
{"name": "Card 1"},
{"name": "Card 10"},
{"name": "Card 2"}
]
Run Code Online (Sandbox Code Playgroud)
我该如何纠正?
https://myshare.sharepoint.com/:x:/s/software/Mks12aSccSS-bsaSJdBFBc1dkns?e=QeL6At
这是我从浏览器复制的 URL(这只是示例)。我如何使用 NodeJS 从中读取内容?
任何想法?
node.js ×6
mongodb ×4
aggregation ×1
eslint ×1
google-api ×1
google-oauth ×1
group-by ×1
javascript ×1
lint ×1
mongoose ×1
nestjs ×1
oauth ×1
sharepoint ×1
typescript ×1