尝试运行无服务器时收到以下警告。
无服务器警告 -------------------------------------
找不到满足声明 'opt:stage' 的有效选项。下面是我的 serverless.yml 文件
# Serverless Config
service: api-service
# Provider
provider:
name: aws
runtime: nodejs8.10
region: ${opt:region, 'ap-east-1'}
stage: ${opt:stage, 'dev'}
# Enviroment Varibles
environment:
STAGE: ${self:custom.myStage}
MONGO_DB_URI: ${file(./serverless.env.yml):${opt:stage}.MONGO_DB_URI}
LAMBDA_ONLINE: ${file(./serverless.env.yml):${opt:stage}.LAMBDA_ONLINE}
# Constants Varibles
custom:
# environments Variables used for convert string in upper case format
environments:
myStage: ${opt:stage, self:provider.stage}
stages:
- dev
- qa
- staging
- production
region:
dev: 'ap-east-1'
stage: 'ap-east-1'
production: 'ap-east-1'
# Function
functions:
testFunc:
handler: index.handler
description: ${opt:stage} API's …Run Code Online (Sandbox Code Playgroud) 我想删除字符串中间的空格,$.trim()例如:
console.log($.trim("hello, how are you? "));
Run Code Online (Sandbox Code Playgroud)
我明白了:
hello, how are you?
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到
hello, how are you?
Run Code Online (Sandbox Code Playgroud)
谢谢.
Mongodb系列 -
[
{ name: 'name 1', call: 'Success Call' },
{ name: 'name 1', call: 'Repeat Call' },
{ name: 'name 3', call: 'Repeat Call' },
{ name: 'name 3', call: 'Unsuccess Call' }
{ name: 'name 2', call: 'Success Call' },
{ name: 'name 2', call: 'Repeat Call' }
{ name: 'name 2', call: 'Repeat Call' }
{ name: 'name 2', call: 'Unsuccess Call' }
.
.
.
.
]
Run Code Online (Sandbox Code Playgroud)
我遵循这个链接组并使用聚合框架对多个列求和,最后得到了这个输出.
[
{
"_id": 1,
"Calls": …Run Code Online (Sandbox Code Playgroud) 我想定义我自己的静态/方法来保存我的模型的文档.
我试过这个:
userSchema.statics.saveUser = function(data, callback){
data.save(callback);
};
Run Code Online (Sandbox Code Playgroud)
它说data.save()不是一个函数.它无法识别该功能.
然后我试了这个
userSchema.statics.saveUser = function(data, callback){
data = new userSchema(data);
data.save(callback);
};
Run Code Online (Sandbox Code Playgroud)
userSchema不是一个函数.
mongodb ×2
aws-lambda ×1
javascript ×1
jenkins ×1
jquery ×1
mongoose ×1
node.js ×1
serverless ×1