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
import React, { Component, Fragment } from 'react' | |
import Departments from './components/Departments' | |
import Users from './components/Users' | |
import './index.css' | |
class App extends Component { | |
render() { | |
return ( |
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
import React, { Component } from 'react' | |
import { getDepartments } from '../services/api' | |
class Departments extends Component { | |
getDepartments = async () => { | |
const response = await getDepartments() | |
console.log({ 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
import React, { Component } from 'react' | |
import { getUsers } from '../services/api' | |
class Users extends Component { | |
getUsers = async () => { | |
const response = await getUsers() | |
console.log({ 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
import { users, departaments } from '../mock' | |
export const getUsers = async () => { | |
return new Promise(resolve => setTimeout(() => { | |
resolve(users) | |
}, 2000)) | |
} | |
export const getDepartments = async () => { | |
return new Promise(resolve => setTimeout(() => { |
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
export const users = [{ | |
id: 1, | |
first_name: "Giffy", | |
last_name: "Crookall", | |
email: "gcrookall0@dmoz.org", | |
gender: "Male" | |
}, { | |
id: 2, | |
first_name: "Dolli", | |
last_name: "Pochet", |
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
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import App from './App' | |
import registerServiceWorker from './registerServiceWorker' | |
ReactDOM.render(<App />, document.getElementById('root')) | |
registerServiceWorker() |
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
import React, { Component } from 'react' | |
import './index.css' | |
class App extends Component { | |
render() { | |
return ( | |
<div> | |
{/* vazio, por enquanto */} | |
</div> |
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
{ | |
"query": { | |
"has_parent": { | |
"parent_type": "users", | |
"query": { // as cláusulas utilizadas nesse objeto serão utilizadas para o documento pai | |
"match": { | |
"name": "Watson" | |
} | |
} | |
} |
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
{ | |
"query": { | |
"has_parent": { // aqui estamos o método has_parent, que efeturá a pesquisa com o pai especificado | |
"parent_type": "users", // buscamos os documentos que tenham como pai, os documentos "users" | |
"query": { | |
"match_all": {} // buscando todos os resultados | |
} | |
} | |
} | |
} |
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
{ | |
"title": "This is a user post 2", | |
"body": "This is a body...", | |
"_JOIN_": { | |
"name": "posts", | |
"parent": "2" // aqui estamos especificando o ID do usuário "John Lenon" | |
} | |
} |