Thursday, 23 November 2017
Wednesday, 22 November 2017
dynamoDb query list
list table
------------------------
var params={};
dynamodb.listTables(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
data.TableNames.forEach((t)=>{
console.log(t);
});
}
});
-----------------------------------------------------
Create Table
var params={
TableName:"TestData",
AttributeDefinitions:[
{
AttributeName:"salary",
AttributeType:"S"
},
{
AttributeName:"empid",
AttributeType:"S"
}
],
KeySchema:[
{
AttributeName: "empid",
KeyType: "HASH"
},
{
AttributeName:"salary" ,
KeyType:"RANGE"
}
],
ProvisionedThroughput:{
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
};
dynamodb.createTable(params,function(error,data){
if(error)
{
console.log(error);
}
else{
console.log(data);
}
});
----------------------------------------------------------
Get Table information
--------------------------
dynamodb.describeTable(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
---------------------------------------
Get All Table records.
params={
TableName:"TestData"
};
docClient.scan(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
----------------------------------------------------
Put Item in dynamodb table
---------------------------------
params={
TableName:"TestData",
Item:{
"empid":"1002","empname":"nagendra","salary":"60000"
}
};
docClient.put(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
------------------------
var params={};
dynamodb.listTables(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
data.TableNames.forEach((t)=>{
console.log(t);
});
}
});
-----------------------------------------------------
Create Table
var params={
TableName:"TestData",
AttributeDefinitions:[
{
AttributeName:"salary",
AttributeType:"S"
},
{
AttributeName:"empid",
AttributeType:"S"
}
],
KeySchema:[
{
AttributeName: "empid",
KeyType: "HASH"
},
{
AttributeName:"salary" ,
KeyType:"RANGE"
}
],
ProvisionedThroughput:{
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
};
dynamodb.createTable(params,function(error,data){
if(error)
{
console.log(error);
}
else{
console.log(data);
}
});
----------------------------------------------------------
Get Table information
--------------------------
dynamodb.describeTable(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
---------------------------------------
Get All Table records.
params={
TableName:"TestData"
};
docClient.scan(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
----------------------------------------------------
Put Item in dynamodb table
---------------------------------
params={
TableName:"TestData",
Item:{
"empid":"1002","empname":"nagendra","salary":"60000"
}
};
docClient.put(params,function(error,data){
if(error)
{
console.log(error);
}
else
{
console.log(data);
}
});
Tuesday, 21 November 2017
dynomodb local
http://www.isostech.com/blogs/software-development/develop-locally-use-dynamodb-local/
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8888
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8888
event emitter
var EventEmitter = require("events").EventEmitter;
var ee = new EventEmitter();
ee.on("someEvent", function () { console.log("event 1");
for(var i=0;i<101;i<i++)
{
console.log(i);
}
});
ee.on("one", function () { console.log("event 2"); });
ee.on("two", function () { console.log("event 3"); });
ee.on("three", function () { console.log("event 4"); });
ee.on("four", function () { console.log("event 5"); });
ee.on("five", function () { console.log("event 6"); });
ee.on("six", function () { console.log("event 7"); });
ee.on("seven", function () { console.log("event 8"); });
ee.on("someEvent", function () { console.log("event 9"); });
ee.on("someEvent", function () { console.log("event 10"); });
ee.on("someEvent", function () { console.log("event 11"); });
ee.emit("one");
ee.emit("two");
ee.emit("three");
ee.emit("four");
ee.emit("five");
ee.emit("six");
ee.emit("seven");
ee.emit("someEvent");
link https://repl.it/repls/ColossalTrueZebratailedlizard
var ee = new EventEmitter();
ee.on("someEvent", function () { console.log("event 1");
for(var i=0;i<101;i<i++)
{
console.log(i);
}
});
ee.on("one", function () { console.log("event 2"); });
ee.on("two", function () { console.log("event 3"); });
ee.on("three", function () { console.log("event 4"); });
ee.on("four", function () { console.log("event 5"); });
ee.on("five", function () { console.log("event 6"); });
ee.on("six", function () { console.log("event 7"); });
ee.on("seven", function () { console.log("event 8"); });
ee.on("someEvent", function () { console.log("event 9"); });
ee.on("someEvent", function () { console.log("event 10"); });
ee.on("someEvent", function () { console.log("event 11"); });
ee.emit("one");
ee.emit("two");
ee.emit("three");
ee.emit("four");
ee.emit("five");
ee.emit("six");
ee.emit("seven");
ee.emit("someEvent");
link https://repl.it/repls/ColossalTrueZebratailedlizard
Monday, 20 November 2017
Sunday, 19 November 2017
object manupulation
data.forEach((x)=>{
if(x.city=="BARRE"){
let o=data.indexOf(x);
let oo=data.splice(0,0,x);
console.log(oo);
console.log(o);
console.log(x.city);
}
})
data.forEach((x)=>{
if(x.city=="BARRE"){
let o=data.indexOf(x);
delete data[o];
data.unshift(x);
}
})
//write code for first element
let data=[{ "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA", "_id" : "01001" },
{ "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA", "_id" : "01002" },
{ "city" : "BARRE", "loc" : [ -72.10835400000001, 42.409698 ], "pop" : 4546, "state" : "MA", "_id" : "01005" },
{ "city" : "BELCHERTOWN", "loc" : [ -72.41095300000001, 42.275103 ], "pop" : 10579, "state" : "MA", "_id" : "01007" },
{ "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240, "state" : "MA", "_id" : "01008" },
{ "city" : "BRIMFIELD", "loc" : [ -72.188455, 42.116543 ], "pop" : 3706, "state" : "MA", "_id" : "01010" },
{ "city" : "CHESTER", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state" : "MA", "_id" : "01011" }]
if(x.city=="BARRE"){
let o=data.indexOf(x);
let oo=data.splice(0,0,x);
console.log(oo);
console.log(o);
console.log(x.city);
}
})
data.forEach((x)=>{
if(x.city=="BARRE"){
let o=data.indexOf(x);
delete data[o];
data.unshift(x);
}
})
//write code for first element
let data=[{ "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA", "_id" : "01001" },
{ "city" : "CUSHMAN", "loc" : [ -72.51564999999999, 42.377017 ], "pop" : 36963, "state" : "MA", "_id" : "01002" },
{ "city" : "BARRE", "loc" : [ -72.10835400000001, 42.409698 ], "pop" : 4546, "state" : "MA", "_id" : "01005" },
{ "city" : "BELCHERTOWN", "loc" : [ -72.41095300000001, 42.275103 ], "pop" : 10579, "state" : "MA", "_id" : "01007" },
{ "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240, "state" : "MA", "_id" : "01008" },
{ "city" : "BRIMFIELD", "loc" : [ -72.188455, 42.116543 ], "pop" : 3706, "state" : "MA", "_id" : "01010" },
{ "city" : "CHESTER", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state" : "MA", "_id" : "01011" }]
Thursday, 16 November 2017
aws cloud search with aws api getway
http://aaronkenny.com/blog/using-aws-api-gateway-to-enable-cors-for-cloud-search/index.htm
Subscribe to:
Posts (Atom)