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
alias gs='git status' | |
alias gst='git status -sb' | |
alias ga='git add .' | |
alias gau='git add -u' # Removes deleted files | |
alias gp='git pull' | |
alias gpu='git push' | |
alias gc='git commit -v' | |
alias gca='git commit -v -a' # Does both add and commit in same command, add -m 'blah' for comment | |
alias gco='git checkout' | |
alias gl='git log --oneline' |
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 elasticsearch from "elasticsearch"; | |
let elasticClient; | |
export const getElasticInstance = () => { | |
if (elasticClient) | |
return elasticClient; | |
elasticClient = new elasticsearch.Client({ | |
host: 'localhost:9200' | |
}); | |
return elasticClient; |
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 mongoosastic from "mongoosastic"; | |
import {getElasticInstance} from "../elastic-search"; | |
//... your schema defination | |
YourSchame.plugin(mongoosastic, { | |
esClient: getElasticInstance() | |
}); | |
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
db.Users.aggregate( | |
[ | |
{ | |
$lookup: { | |
"from" : "UsersSubscriptions", | |
"localField" : "_id", | |
"foreignField" : "user_id", | |
"as" : "subscriptions" | |
} | |
}, |
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
{ | |
"_id" : ObjectId("5a36ce46f7a13634daf1214c"), | |
"name" : "Jayden", | |
"created_at" : ISODate("2017-12-14T12:49:01.746+0000"), | |
"subscriptions" : [ | |
{ | |
"_id" : ObjectId("5a36ce84f7a13634daf1214e"), | |
"user_id" : ObjectId("5a36ce46f7a13634daf1214c"), | |
"topic" : "nodejs" | |
}, |
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 buttonStyle = { | |
fontSize: "1em", | |
margin: "1em", | |
padding: "0.25em 1em", | |
border: "2px solid palevioletred", | |
borderRadius: 3, | |
color: "white", | |
background: "palevioletred" | |
}; |
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
componentWillReceiveProps(nextProps) { | |
if (nextProps.pageNo !== this.state.pageNo) { | |
this.setState({ pageNo: nextProps.pageNo }); | |
fetchNextPageData(nextProps.pageNo); | |
} | |
} |
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
static getDerivedStateFromProps(nextProps, prevState) { | |
if (prevState.pageNo !== nextProps.pageNo) { | |
return { pageNo: nextProps.pageNo }; | |
} | |
} | |
componentDidUpdate(prevProps) { | |
if (prevProps.pageNo !== this.props.pageNo) { | |
fetchNextPageData(this.props.pageNo); | |
} |
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
componentWillMount() { | |
this.setState({ loading: true }); | |
this.props.fetchData(); // action dispatch | |
} |
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
constructor(props) { | |
super(props); | |
this.state = { loading: true }; | |
} | |
componentDidMount() { | |
this.props.fetchData(); // action dispatch | |
} |
OlderNewer