New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@giftwizard/db-models

Package Overview
Dependencies
Maintainers
7
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@giftwizard/db-models - npm Package Compare versions

Comparing version 8.0.0 to 8.0.1

models/map-gift-to-cards.js

94

models/customer.js

@@ -41,7 +41,7 @@ module.exports = (sequelizeConnection, DataTypes, Sequelize) => {

const offset = parseInt(page) * limitInt - limitInt;
try {
const { rows, count } = await Customer.findAndCountAll({
const result = await Customer.findAll({
limit: limitInt,
offset,
attributes: ['email', 'first_name', 'last_name', 'state'],
include: [

@@ -53,2 +53,3 @@ {

{
attributes: ['balance', 'code'],
model: sequelizeConnection.models.GiftCard,

@@ -61,8 +62,12 @@ required: true

where: {
shop_url
shop_url,
loyalty_card_id: {
[Op.ne]: null,
}
},
order: [[sequelizeConnection.models.LoyaltyCard, { model: sequelizeConnection.models.GiftCard }, 'balance', 'desc']]
order: [['updated_at', 'DESC']]
});
return { rows, count };
return { rows: result, count: 100 };
} catch (error) {

@@ -157,2 +162,78 @@ throw new Error(`Unable to get all customers page - ${page} for shop - ${shop_url}, ${error}`);

Customer.getCustomersSearchByEmail = (shop_url, search) => {
const sanitizedSearchQuery = search.trim().toLowerCase();
const searchQueryTokens = sanitizedSearchQuery.split(/\s+/);
const fields = ['email'];
const operatorsFields = fields.map(field => {
return {
[Op.or]: searchQueryTokens.map(token =>
sequelizeConnection.where(sequelizeConnection.fn('lower', sequelizeConnection.col(field)), 'LIKE', `%${token}%`)
)
};
});
return Customer.findAll({
limit: 20,
where: {
shop_url,
[Op.or]: operatorsFields
},
include: [
{
model: sequelizeConnection.models.LoyaltyCard,
include: [
{
model: sequelizeConnection.models.GiftCard
}
]
}
]
})
.then(customers => {
return customers;
})
.catch(error => {
throw new Error(`Unable to search customers for shop - ${shop_url}, ${error}`);
});
};
Customer.getCustomersSearchByName = (shop_url, search) => {
const sanitizedSearchQuery = search.trim().toLowerCase();
const searchQueryTokens = sanitizedSearchQuery.split(/\s+/);
const fields = ['first_name', 'last_name'];
const operatorsFields = fields.map(field => {
return {
[Op.or]: searchQueryTokens.map(token =>
sequelizeConnection.where(sequelizeConnection.fn('lower', sequelizeConnection.col(field)), 'LIKE', `%${token}%`)
)
};
});
return Customer.findAll({
limit: 20,
where: {
shop_url,
[Op.or]: operatorsFields
},
include: [
{
model: sequelizeConnection.models.LoyaltyCard,
include: [
{
model: sequelizeConnection.models.GiftCard
}
]
}
]
})
.then(customers => {
return customers;
})
.catch(error => {
throw new Error(`Unable to search customers for shop - ${shop_url}, ${error}`);
});
};
Customer.updateLoyaltyCard = (shop_url, customerId, giftCardId) => {

@@ -175,3 +256,3 @@ return sequelizeConnection.models.LoyaltyCard.create({ gift_card_id: giftCardId })

}
).then(() => {});
).then(() => { });
})

@@ -185,1 +266,2 @@ .catch(error => {

};

2

package.json
{
"name": "@giftwizard/db-models",
"version": "8.0.0",
"version": "8.0.1",
"description": "Rise.ai package for 'sequelize' models used by several projects.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc