我有一个 lambda 来连接到 SQL Server 数据库,如下所示。
module.exports = async (event) => {
const sqlClient = getConnection(); // connection to ms SQL
doMyWork(sqlConnection) // my core lambda logic
closeConnection(sqlConnection) // closing Connection
}
Run Code Online (Sandbox Code Playgroud)
当 lambda 被触发时,我的 SQL Server 就会连接,工作完成并关闭连接。有没有一种方法可以让我在 lambda 的多次调用中使用连接对象,以便我可以减少 a) 不。b) 减少 lambda 的整体执行时间?
我在这里提到了 SQL Server,因为我目前正在这里使用它。因此我必须连接到 MySQL 和 redis。连接数据库的推荐方式是什么(尤其是哪些支持池)?
请建议。
我希望我的卡看起来像下面这样
我保持这样的布局
<android.support.v7.widget.CardView
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Order# GAMH2103"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:gravity="start"
android:textSize="15dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Confirmed"
android:drawableRight="@drawable/check"
android:textColor="#00FF00"
android:gravity="end"
android:textSize="15dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
android:layout_marginTop="5dp"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
不知何故,我无法看到"已确认"的TextView.我可以看到#的订单.
我打同gravity和layout_gravity,但不知何故打不通.
请帮忙.
谢谢,拉克什曼.
android android-layout android-linearlayout android-cardview
我需要在客户数据库上编写动态查询,以获得客户的少数字段.
以下是代码
[Route("api/getBasicCustList/{argType}/{argValue}")]
[HttpGet]
[Authorize]
public dynamic getCustomerDataUsername(String argType, String argValue)
{
IQueryable<CustomerDTO> query =
(from recordset in db.Customers
select new CustomerDTO
{
companyId = recordset.Company.Id,
contactNum = recordset.ContactNum,
username = recordset.UserName,
emailAddress = recordset.Email,
fullName = recordset.FullName,
accountNumber = recordset.RCustId
}
);
switch (argType)
{
case "username" :
query = query.Where(c => c.username.StartsWith(argValue));
break;
case "contactnum":
long mobNum = Int64.Parse(argValue);
query = query.Where(c => c.contactNum == mobNum);
break;
case "fullname":
query = query.Where(c => c.fullName.Contains(argValue));
break;
}
return new …Run Code Online (Sandbox Code Playgroud) 我不能允许我在以angularjs构建的表单中的未来日期
这是我的HTML:
<div ngCloak ng-app="laurelMoney" ng-controller="myCtrl">
<form name="userForm">
<div class="form-group">
<input type='date' id="trandate" class="form-control" ng-model="trandate" required ng-class="{ 'has-error' : userForm.trandate.$error }" />
<p ng-show="userForm.trandate.$error" class="help-block">Transaction can't be in future</p>
</div>
<a href="#" class="btn btn-primary btn-sm btn-block" ng-click="submitForm()" type="submit">Add Transaction</a>
</form>
Run Code Online (Sandbox Code Playgroud)
我的javascript是Ñ
angular.module('laurelMoney', [])
.controller('myCtrl', function($scope) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd
}
if (mm < 10) …Run Code Online (Sandbox Code Playgroud) 我使用 mysql 5.7 版
我有一个现场设备时间,这是一个datetime领域。
出于某种原因,我想添加一个生成的列,该列仅存储设备date时间字段的一部分。
我已经尝试了以下声明
alter table mytable
add COLUMN recorddate date generated always as date(devicetime) stored;
Run Code Online (Sandbox Code Playgroud)
我得到一个错误
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'date(devicetime) stored' at line 2
Run Code Online (Sandbox Code Playgroud)
我从这个链接中获取了 MySQL 文档的输入。
我目前的表结构是这样的
我有三个(nodejs)进程P1,P2,P3。
P1的功能A完成其执行,它将一些数据发送到P2。
P2执行其活动,其输出应发送到P3。
P3在输入上工作,向P1的功能B发送一些确认数据。
这三个都是不同的节点js应用程序,并且在不同的服务器(在同一LAN中)上运行。问题是what should be the communication mechanism between these processes.
三种选择似乎是可行的:
1)REST API(快速)
让所有进程成为Express REST API,并使用httpnode js包调用所需的函数
2)发布/订阅
当P1完成工作时,它将输出作为消息发布到主题,P2成为订阅者,onMessageP2进程执行。
3)TCP / IP
一个简单的TCP / IP服务器-客户端体系结构,其中P1成为服务器客户端,P2作为服务器。只要P1完成工作,就通过套接字发送输出。
所有这三个选项都用于多对一或多对多通信,所以我猜可能会有很多不必要的开销,因为我的要求在进程之间只有一对一的通信。
我还有其他方法可以使用吗,或者这些最佳方法之一就是两难。
请提出建议。
谢谢。
是的,论坛中有很多问题,但不知何故对我不起作用。我不是很特别。
我的自动完成正在填充结果,但结果没有被过滤
我的代码是:
$("#empName").autocomplete({
source: function(request, response) {
$.ajax({
url: "api/clientEmp/of/" + sessionClientId + "/notingroup/" + groupId,
type: "GET",
dataType: "json",
data: {
term: $("#empName").val()
},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.EmpName,
value: item.EmpId
};
}));
}
});
},
minLength: 0,
focus: function(event, ui) {
$("#empName").val(ui.item.label);
}
});
Run Code Online (Sandbox Code Playgroud)
json 输出是这样的
[
{
"EmpId": 26,
"EmpNum": "Rel-72015-31",
"EmpName": "R.durai"
},
{
"EmpId": 21,
"EmpNum": "REL-42015-22",
"EmpName": "Zishan"
},
{
"EmpId": 56,
"EmpNum": "Rel-22015-19",
"EmpName": "Raj Singh"
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习AngularJS并开始我的第一个代码示例来获取用户的github repos.
我的html页面是这样的:
<!DOCTYPE html>
<html ng-app="githubViewer">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="gitHubRepoController">
{{error}}
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Full Name</th>
<th>HTML Url</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="repo in repos">
<td>{{repo.name}}</td>
<td>{{repo.full_name}}</td>
<td>{{repo.html_url}}</td>
<td>{{repo.description}}</td>
</tr>
</tbody>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的控制器是这样的
(function() {
var app = angular.module("githubViewer",[]);
var gitHubRepoController = function($scope, $http){
$http.get("https://api.github.com/users/lakshman553/repos")
.then(onDataDownloaded, onError);
var onDataDownloaded = function(response) {
console.log(response.data);
$scope.repos = response.data;
};
$scope.error = "some value";
var onError = function(reason) …Run Code Online (Sandbox Code Playgroud) angularjs ×2
javascript ×2
android ×1
autocomplete ×1
aws-lambda ×1
c# ×1
jquery ×1
mysql ×1
node.js ×1
publish ×1
rest ×1
sockets ×1
sql-server ×1
tcp ×1