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
SELECT Domain from bill_items group by Domain; | |
select | |
Domain, | |
Product_Name, | |
sum(Amount) as total, | |
DATEPART(Month, Start_Date) as Month, | |
DATEPART(Year, Start_Date) as Year | |
from bill_items | |
group by |
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
[ | |
{ | |
"Domain": "trademotion.com" | |
}, | |
{ | |
"Domain": "tuilifestyle.com" | |
}, | |
{ | |
"Domain": "selectiveps.com" | |
}, |
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
#!/bin/bash | |
rm -rf $PWD/$1 | |
mkdir $PWD/$1 | |
var1=$1 | |
name=`echo -n "${var1}" | sed -e 's/-/ /g' -e 's/\b\(.\)/\u\1/g' -e 's/ //g' ` | |
echo "import React from 'react'; | |
import './"$1".scss'; |
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
#!/bin/bash | |
rm -rf $PWD/$1 | |
mkdir $PWD/$1 | |
var1=$1 | |
name=`echo -n "${var1}" | sed -e 's/-/ /g' -e 's/\b\(.\)/\u\1/g' -e 's/ //g' ` | |
echo "import React, { Component } from 'react'; | |
import './"$1".scss'; |
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
await UsersDb.models.user.findOne({ | |
where: { id: 1 }, | |
include: { | |
model: UsersDb.models.order, | |
include: { | |
model: ProductsDb.models.product, | |
on: { | |
order_id: Sequelize.literal("`orders`.`id` = `orders->products`.`order_id`") | |
// you can always refer the generated query to get | |
// the exact column names for the literal string |
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 product = await UsersDb.models.order.findOne({ | |
where: { id: 1 }, | |
include: [ | |
{ | |
model: ProductsDb.models.product, | |
on: { | |
// this is where magic happens | |
order_id: Sequelize.literal("`order`.`id` = `products`.`products`.`order_id`") | |
} | |
} |
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
// models/product.js | |
... | |
{ | |
tableName: "product", | |
timestamps: false, | |
schema: "products" // add this line | |
} | |
... |
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 ProductsDb = new Sequelize(config.productsDatabaseName, config.username, config.password, config.options); | |
ProductsDb.dialect.supports.schemas = true; // add this line | |
ProductsDb.import("models/product.js"); | |
... |
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
await UsersDb.models.order.findOne({ | |
where: { id: 1 }, | |
include: [ProductsDb.models.product] | |
}); | |
// SequelizeDatabaseError: Table 'users_and_orders.product' doesn't exist |
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
UsersDb.models.user.hasMany(UsersDb.models.order, { foreignKey: "user_id" }); | |
UsersDb.models.order.hasMany(ProductsDb.models.product, { foreignKey: "order_id" }); |