mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
static data generation with cache
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Db } from "mongodb";
|
||||
|
||||
/**
|
||||
* Converts date from string into a date to allow ordering
|
||||
*/
|
||||
export const dateOrderingFrance = async (db: Db) => {
|
||||
return await db
|
||||
.collection("tournaments")
|
||||
.aggregate([
|
||||
{
|
||||
$addFields: {
|
||||
dateParts: {
|
||||
$dateFromString: {
|
||||
dateString: "$date",
|
||||
format: "%d/%m/%Y",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
dateParts: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unset: "dateParts",
|
||||
},
|
||||
])
|
||||
.toArray();
|
||||
};
|
||||
Reference in New Issue
Block a user