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
## findAndModify | |
Lembrando da aula anterior quando falei que a busca com `findOne` retorna um cursor onde você deve iterar nele para buscar seus dados, hoje veremos a diferença dele para o `findAndModify`. | |
FindAndModify() modifica e retorna um único documento com no campo chave de seleção inseridos. Nessa busca o documento não retorna o conteúdo atualizado por padrão caso o campo chave não exista no banco de dados um novo registro é inserido e se o upsert seja definido como true. | |
Esquema do findAndModify(): | |
``` |
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
const express = require('express') | |
const router = express.Router() | |
const passport = require('passport') | |
const Controller = require("./organism") | |
const authenticate = require('./_organelles/organelles-validate-login') | |
// Create | |
router.post('/', Controller.add) | |
// get current user |
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
{ | |
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Tomorrow.tmTheme", | |
"e4x": true, | |
"font_size": 15, | |
"format_on_save": true, | |
"format_on_save_extensions": | |
[ | |
"js", | |
"json", | |
"jsx" |
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
var x = 1; | |
var y = 2; | |
var z = 3; | |
function soma(x,y,z) { | |
return x+y+z | |
} | |
var recebe = soma(x,y,z) |
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
/* eslint-disable global-require */ | |
const mongoose = require('mongoose'); | |
mongoose.Promise = require('bluebird'); | |
const online = false; | |
const url = online ? '' : 'mongodb://localhost/'; | |
const options = { | |
db: { native_parser: true }, |
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
const request = require('request'); | |
const cheerio = require('cheerio'); | |
const moment = require('moment'); | |
const date = moment(new Date(), 'DD/MM/YYYY'); | |
const url = 'http://www.futebol365.pt/probabilidades/?schedule_date_input='; | |
const search = date.format('YYYY-MM-DD'); | |
const campeonato = []; | |
request(url + '2017-04-15', (err, res, 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
const axio = require('axios') | |
const url = 'https://api.playbets.com.br/painel/update/list' | |
axio.get(url) | |
.then(response =>{ | |
let objetoCompost = []; | |
let regras = []; | |
const object = response.data.campeonatos; | |
object.map((campeonato,index) => { | |
let retornoObject = {}; |
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
const axio = require('axios') | |
const base1 = `https://jsonplaceholder.typicode.com/comments` | |
/* | |
1) Pegar todos os dados que tiver postId 1 filter / reduce | |
*/ | |
const compararFilter = objeto => objeto.postId <= 1 | |
//filter | |
axio.get(base1).then(response => { |
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
const multiparty = require('multiparty'); | |
const pass = require('../middleware/password') | |
const fs = require('fs') | |
const path = require('path') | |
function configPass (v) { | |
return pass.hash(v) | |
} | |
function cryptImage(fileName){ |
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
module.exports = (value)=>{ | |
console.log(value) | |
var cpf = value; | |
//exp = /.|-/g | |
//cpf = cpf.toString().replace( exp, "" ); | |
var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10)); | |
var soma1=0, soma2=0; | |
var vlr =11; | |
for(i=0;i<9;i++){ | |
soma1+=eval(cpf.charAt(i)*(vlr-1)); |
OlderNewer