This file contains hidden or 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 vectorName = '_search'; | |
const searchObjects = { | |
authors: ['name', 'biography'], | |
posts: ['name', 'summary'], | |
}; | |
module.exports = { | |
up: (queryInterface) => ( | |
queryInterface.sequelize.transaction((t) => |
This file contains hidden or 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 { map } from 'lodash'; | |
import models from 'src/models'; | |
const search = async function search() { | |
const results = await models.sequelize.query(` | |
SELECT * | |
FROM ${models.Author.tableName} | |
WHERE _search @@ plainto_tsquery('english', :query); | |
`, { |
This file contains hidden or 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 Enzyme from 'enzyme'; | |
import { JSDOM } from 'jsdom'; | |
import initialize from 'src/initialize'; | |
// Initialize our project | |
initialize(); | |
// Force the test environment | |
process.env.NODE_ENV = 'test'; |
This file contains hidden or 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 { mount as enzymeMount } from 'enzyme'; | |
import createHistory from 'history/createMemoryHistory'; | |
import React from 'react'; | |
import { Provider } from 'react-redux'; | |
import { ConnectedRouter } from 'react-router-redux'; | |
import Immutable from 'seamless-immutable'; | |
import initialize from 'src/store/initialize'; | |
/** |
This file contains hidden or 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 { | |
filter, | |
} from 'lodash'; | |
/** | |
* A global hook which is applied to every model's create, update and destroy lifecycle | |
* methods. Once one of those lifecycle event's occurs, this function iterates over | |
* every other model definition looking for cache columns which point to the triggering | |
* model. If any models are found, their cache counter coulmns are then updated. | |
* |
This file contains hidden or 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
this.Comment = this.sequelize.define('comment', { | |
title: Sequelize.STRING, | |
commentable: Sequelize.STRING, | |
commentable_id: Sequelize.INTEGER | |
}); | |
this.Comment.prototype.getItem = function() { | |
return this['get' + this.get('commentable').substr(0, 1).toUpperCase() + this.get('commentable').substr(1)](); | |
}; |
This file contains hidden or 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
/** | |
* Given a comment which has polymorphic associations of post and photo. | |
*/ | |
const comments = await models.Comment.findAll({ | |
include: [ | |
{ model: models.Photo }, | |
{ model: models.Post }, | |
], | |
}); |
This file contains hidden or 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 paranoidDeleteCascade from './helpers/paranoidDeleteCascade'; | |
// Patch the paranoid delete functionality of Sequelize | |
sequelize.addHook('afterDestroy', paranoidDeleteCascade(db)); |
This file contains hidden or 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 get from 'lodash/get'; | |
import PropTypes from 'prop-types'; | |
import React from 'react'; | |
import { connect } from 'react-redux'; | |
/** | |
* Higher-order component that passes state and props into a predicate that | |
* checks whether the current user has permission to view the page due to paywall restrictions. | |
* | |
* If the predicate function returns true, the component is rendered. |
OlderNewer