javascript - 如何在不重复 Laravel 的情况下合并拖曳数组
问题描述
我可以制作一个 crud mongo,但我需要将 mongo mysql 与来自 mongo 的特定 col 关联或合并我有一个集合 Notes,每个文档都有,
{
"_id":{"$oid":"607f2cdf24670000e40066c9"},
"curse_id":47,
"secion":"A",
"block":4,
"activities":[],
"scores":[]
}
在 mysql 中,我有一张桌子,那里有学生
id name Curse secion
1 Jon 47 A
2 Matew 47 A
3 Jane 48 B
4 Joly 48 A
case 1 Get all students with own cols where curse 74 seccion A from mongo 注意 -> 分数需要存储和更新 cols{} 分数,问题是 case2
案例 2 从 mysql 获取诅咒 74 seccion A 的所有学生文档注释 -> 分数
“分数”:[
{“id”:1, “Jon” , cols{2:10, 3:20} }, {“id”:2, “Matew”, cols{2:50, 3:60} },
]
我将创建 cols dinamicals
控制器 laravel student.php
function getDocStudents(){
$docID =[
"curso_id"=> (int) $request->curso_id,
"seccion"=> $request->seccion
];
$nota = Notes::where($docID)->first(); //mongo
if(is_null($nota)){
$nota = new Notes();
$nota->curse_id = $request->curse_id,
$nota->seccion = $request->section
$nota->block = $request->block;
$nota->activities = [];
$nota->scores = [];
$nota->save();
}
$resp['student'] = Students::where($docID)->get(); //come from mysql
$resp['doc'] = $nota;
return response()->json($resp);
}
解决方案
推荐阅读
- solana - NFT 代币如何与资产相关联(例如图像、视频)
- html - 一个按钮是白色的,直到光标在它上面。所有其他按钮均为蓝色
- python - 如何映射和连接值两个数据框python
- python - 如何从谷歌驱动器检索图像链接并使用 GridFS 将其上传到 MongoDB?
- javascript - 样式化 rc-slider 轨道以在其内部包含句柄
- java - Flutter Downloder 失败,错误是找不到具有权限的提供者的元数据
- c# - ReadOnlyMemory<> 和 ReadOnlySequence<> 类型在未引用的程序集中定义
- algorithm - 线性搜索的平均案例复杂度
- r - 有没有办法根据数据集中的列折叠系统发育树(R)
- php - 将 .php 扩展名添加到 Wordpress 中的一个插件页面