Merge branch 'master' of github.com:medusajs/medusa
This commit is contained in:
commit
b34bdd2c49
5 files changed
+27
-15
No files matched your search
@@ -9,9 +9,14 @@ export default async (req, res) => {
|
|||||||
"last_name",
|
"last_name",
|
||||||
])
|
])
|
||||||
|
|
||||||
const customers = await customerService.list(query)
|
const limit = parseInt(req.query.limit) || 0
|
||||||
|
const offset = parseInt(req.query.offset) || 0
|
||||||
|
|
||||||
res.json({ customers })
|
const customers = await customerService.list(query, offset, limit)
|
||||||
|
|
||||||
|
const numCustomers = await customerService.count()
|
||||||
|
|
||||||
|
res.json({ customers, total_count: numCustomers })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const orderService = req.scope.resolve("orderService")
|
const orderService = req.scope.resolve("orderService")
|
||||||
const order = await orderService.archive(id)
|
let order = await orderService.archive(id)
|
||||||
|
order = await orderService.decorate(order, [], ["region"])
|
||||||
res.json({ order })
|
res.json({ order })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
@@ -113,8 +113,16 @@ class CustomerService extends BaseService {
|
|||||||
* @param {Object} selector - the query object for find
|
* @param {Object} selector - the query object for find
|
||||||
* @return {Promise} the result of the find operation
|
* @return {Promise} the result of the find operation
|
||||||
*/
|
*/
|
||||||
list(selector) {
|
list(selector, offset, limit) {
|
||||||
return this.customerModel_.find(selector)
|
return this.customerModel_.find(selector, {}, offset, limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the total number of documents in database
|
||||||
|
* @return {Promise} the result of the count operation
|
||||||
|
*/
|
||||||
|
count() {
|
||||||
|
return this.customerModel_.count()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -252,21 +252,19 @@ class OrderService extends BaseService {
|
|||||||
// Run all other registered events
|
// Run all other registered events
|
||||||
const completeOrderJob = await this.eventBus_.emit(
|
const completeOrderJob = await this.eventBus_.emit(
|
||||||
OrderService.Events.COMPLETED,
|
OrderService.Events.COMPLETED,
|
||||||
result
|
order
|
||||||
)
|
)
|
||||||
|
|
||||||
await completeOrderJob.finished().catch(error => {
|
await completeOrderJob.finished().catch(error => {
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.orderModel_
|
return this.orderModel_.updateOne(
|
||||||
.updateOne(
|
{ _id: order._id },
|
||||||
{ _id: order._id },
|
{
|
||||||
{
|
$set: { status: "completed" },
|
||||||
$set: { status: "completed" },
|
}
|
||||||
}
|
)
|
||||||
)
|
|
||||||
.then(async result => {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class QueryBuilderService extends BaseService {
|
|||||||
if (_.isEmpty(search)) return
|
if (_.isEmpty(search)) return
|
||||||
|
|
||||||
const searchQuery = searchProperties.map(s => ({
|
const searchQuery = searchProperties.map(s => ({
|
||||||
[s]: new RegExp(search.q),
|
[s]: new RegExp(search.q, "i"),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return { $or: searchQuery }
|
return { $or: searchQuery }
|
||||||
|
|||||||
Reference in new issue
Block a user