我在 mongodb 中有集合,想要按修改对发票进行分组并获取这些对象中的所有字段。
{
modified: "11/02/2020",
stocks: [
{
product:{
name:"Milk",
price: 20
}
quantity: 2,
paid: true
}
]
},
{
modified: "10/02/2020",
stocks: [
{
product:{
name:"Sugar",
price: 50
}
quantity: 1,
paid: false
}
]
},
{
modified: "10/02/2020",
stocks: [
{
product:{
name:"Butter",
price: 10
}
quantity: 5,
paid: false
}
]
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试:
db.collection.aggregate([{
$group: {
_id: "$modified",
records: { $push: "$$ROOT" }
}
}
])
Run Code Online (Sandbox Code Playgroud)
但它在被推入记录的修饰符字段上重新聚合,生成重复项
我正在使用 angular 版本 6.1.0 和电子 2.0,在浏览器中运行应用程序,但在运行 npm run electron-build 时成功,但应用程序无法启动。因此,不显示浏览器窗口。
这是package.json
文件:
{
"name": "front",
"version": "0.0.0",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron-build":"ng build --prod"
}
...
}
Run Code Online (Sandbox Code Playgroud)
这是main.js
文件:
const {app, BrowserWindow} = require('electron');
let win;
function createWindow (){
win = new BrowserWindow({
height: 600,
width:600,
backgroundColor:'#ffffff'
})
win.loadURL(`file://${__dirname}/dist/index.html`)
win.on('closed',function(){
win=null;
})
}
app.on('ready',createWindow())
app.on('windows-all-closed',()=>{
if(process.platform!=='darwin'){
app.quit();
} …
Run Code Online (Sandbox Code Playgroud)