我有一个jsonb列,其中包含用户的数据。我已经能够存储和更新该json列的信息。但是现在我需要删除特定数据。例如,如果用户单击删除按钮,它将删除该索引数据。
"work": [
{
"id": "da4582be-2075-11e9-99db-08002718287a",
"info": "work",
"company": "Augnitive",
"working_to": "2021-05-12",
"designation": "Software Engineer",
"working_from": "2019-11-15",
"responsibilities": "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
}
],
"contact": [],
"personal": [
{
"id": "a8cba4a2-2075-11e9-9b58-08002718287a",
"bday": "1993-07-21",
"info": "personal",
"blood": "B(+VE)",
"gender": "Male"
}
],
"education": [
{
"id": "b1bab9ee-206c-11e9-a640-08002718287a",
"info": "education",
"edu_type": "SSC 1234",
"institute": "PGJHS 2",
"graduation": "2012"
},
{
"id": "b2842910-2075-11e9-a835-08002718287a",
"info": "education",
"edu_type": "HSC",
"institute": "PGC",
"graduation": "2012"
}
]
}
这是我要向其发送数据索引的刀片文件格式
@foreach($profile['education'] as $index => $education)
<table class="table bio-table">
<a href="#delete"
data-toggle="modal"
class="deleteNews btn-danger margin-left float-right"
data-route="{{ route('home.destroy',$education) }}"
data-target="#deleteEducation"><i class="glyphicon glyphicon-trash"></i></a>
**Modal for this :**
<div class="modal fade" id="deleteEducation">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"><i class="fa fa-trash"></i> Delete Page</h4>
</div>
<div class="modal-body">
<h2>Are you sure?</h2><br>
<form action="" method="post">
@csrf
@method('DELETE')
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger">Yes</button>
</form>
</div>
</div>
</div>
</div>
javascript
$(document).ready(function(){
$('.deleteEducation').click(function () {
$('#deleteEducation form').attr('action', $(this).data('route'));
});
});
现在如何删除该数据?
答案 0 :(得分:0)
我不确定,是否可以像这样操作JSON,但也许在不删除要删除的数据的情况下编写JSON新代码可能更容易?