Is there any way where we can insert a BSON Mongo record using go-mongo -> InsertOne
method?
I have a record like this:
{
"_id" : ObjectId("5ef59232fe31f24ac6b54822"),
"batchId" : NumberLong(184486),
"batchName" : "sample",
"createdBy" : "createdSample",
"status" : "CREATED",
"type" : "normal",
"batchType" : "Regular",
"batchStartDate" : ISODate("2020-06-26T00:00:00Z"),
"batchEndDate" : ISODate("2020-08-20T00:00:00Z"),
"size" : 10,
"sector" : {
"id" : "18",
"name" : "Food"
},
"jobRoles" : [
{
"jobName" : "Processed Food",
"qpCode" : "FIC",
"version" : "1.0",
"nsqfLevel" : "6",
"jobRoleDesc" : "",
"attendanceUploaded" : null,
"traingingAttendanceSubmitted" : null,
"assessmentStartDate" : ISODate("2020-08-23T00:00:00Z"),
"assessmentEndDate" : ISODate("2020-08-23T00:00:00Z"),
"isPlatformQP" : false,
"isBaseQP" : false,
"isBatchAssigned" : {
"masterTrainer" : false,
"assessmentAgency" : false
},
"isRejected" : {
"masterTrainer" : false,
"assessmentAgency" : false
},
"sector" : {
"id" : "12",
"name" : "Food Processing"
},
"trainingHoursPerDay" : 6,
"jobRoleCategory" : "3",
"initialAssessmentStartDate" : ISODate("2020-08-23T00:00:00Z"),
"initialAssessmentEndDate" : ISODate("2020-08-23T00:00:00Z"),
"overrideQpHours" : NumberLong(280)
}
],
}
I want to insert this document into MongoDB without the use of struct, wherein the above document will be assigned to a go variable and the record will be inserted using that variable.
Is there any way to achieve this?
Also, I have seen that the bsonx
package has a bsonx.JavaScript
. Is there any way to inset a bsonx datatype into MongoDB using go