This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#################################### | |
# Script para health check # | |
#################################### | |
# Verificando o quanto de memória RAM está sendo utilizado | |
FREEMEMORY="`free -h`" | |
echo $FREEMEMORY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: gcr.io/google-appengine/php:latest | |
pipelines: | |
branches: | |
nome-da-branch: | |
- step: | |
name: Deploy SFTP | |
script: | |
- apt-get update -y | |
- apt-get install -y ssh | |
- mkdir changed_files #Criando pasta auxiliar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firebase.initializeApp({ | |
apiKey: "YOUR apiKey", | |
authDomain: "YOUR authDomain", | |
projectId: "YOUR projectId", | |
}); | |
let firestore = firebase.firestore(); | |
let collection = firestore.collection('Teste'); | |
collection.get().then(result => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let filter = db.datastore.key(['material', db.datastore.int(req.param('id'))]); | |
//Deletando documento | |
db.datastore.delete(filter, function(err, apiResp){ | |
console.log('Document deleted'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Filtrando o item pelo seu ID enviado do método POST | |
let filter = db.datastore.key(['material', db.datastore.int(req.param('id'))]); | |
db.datastore.get(filter, function(err, material){ | |
//Caso, o item or encontrado | |
if (material) { | |
/* Para atualizar os dados de um documento no Datastore, podemos utilizar a mesma função de criação save | |
* ou até mesmo as equivalentes update e upsert, que atualizam ou criam caso o documento não exista */ | |
let item = { | |
key : filter,//iremos reaproveitar a variável, para o Datastore entender que iremos inserir dados para um documento existente | |
data : req.body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cenário onde retornaremos todas as entidades salvas na base | |
let query = db.datastore.createQuery('material');//Configurando a entidade que iremos buscar | |
db.datastore.runQuery(query).then(materials => { | |
console.log(materials[0]);//Dessa forma, acessamos todos os dados retornados pela query | |
}); | |
//Nesse cenário, iremos filtrar por algum atributo da entidade | |
db.datastore.runQuery(query) | |
.filter('name', '=', 'Exemplo')//Filtraremos por todos dados cadastrados que tenham no atributo name o dado Exemplo | |
.filter('quantity', '>', 10)//E que tenham a quantidade maior que 10 | |
.then(materials => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JSON of data | |
let materialKey = db.datastore.key('material');// Chave cloud para a entidade | |
let material = { | |
key: materialKey, | |
data: req.body, | |
}; | |
db.datastore.save(material).then(function(item) { | |
console.log('Material ${materialKey.id} created successfully.'); | |
console.log(item[0].mutationResults[0]);//Se você quiser acessar os dados enviado |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Informando o endereço do arquivo para remoção do mesmo | |
fs.unlink("./files/example.txt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Enviando o caminho do arquivo que queremos renomear e o caminho/nome para sua nova situação | |
fs.rename('./files/example.txt', './files/007.txt', function(err){ | |
//Caso a execução encontre algum erro | |
if(err){ | |
//A execução irá parar e mostrará o erro | |
throw err; | |
}else{ | |
//Caso não tenha erro, apenas a mensagem será exibida no terminal | |
console.log('Arquivo renomeado'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Efetuando a leitura do arquivo | |
fs.readFile('./files/FILE_NAME','utf8', function(err,data){ | |
//Enviando para o console o resultado da leitura | |
console.log(data); | |
}); |
NewerOlder