Hello and welcome to the Golang programming language course in the previous session, U.S. we could
define a single delete function, and in this session we want to define the function name the multiple
delete that accept two parameters.
First parameter is an end to interface, which indicates that any instance of a strike is to be passed
to dismantle.
And second is a very closed string for condition.
Also, dysfunction returns the number of records that have been affected by the delete operation at
the end of the warps.
So go to the DB connection and define our function.
Fine.
Multiple delete set a name like object as any either face object and in the interface
sit very close as string as condition.
Yeah, close by the time this string is condition and set in, 64 has returned, typed in 64.
Now calling connect function for initializing MySchool data source name, this function returns a DV
object from Gore package, which gives us access to matters contained in that package to perform current
operation.
So first, define a variable like DV call and equals end calling connect function.
After creating a deep object from gore and package in what their function and set were, close object
is an argument.
Eat their function at conditions.
So first, define it a bit like resolved Colin equals.
And calling their function on the TV, RG dance, they're.
And set very close a single object as arguments.
And the more the invoked delete function, so we'll be calling delete functions from the object insert
object instance as argument to it.
Don't left
and set object argument, delete function did its value much given conditions, then delete a record
you need to ensure its primary field has value and gore and will use the primary key to delete the record.
If primary fields blank or invalid, delete are records for the mother now invoking those affected field
from resolved return that we showed the remove affected records or we write return result that rules
affected reformat the code and save the project.
We have now succeeded in designing a method to receive airstrike instance from the outside at delete
this object from its table in the database.
Now we go to the main function to use this query statement first to the last code.
In this case, we want to delete all the students who have a special condition in the database, so
we should use from multiple delete function from DV tools.
First, define a condition as very close argument.
Consider that we want to delete a student based on their names, so define the condition based NE.
Define a variable like name.
And we want to say that every record whose name has this value, for example, and name calling equals
team and set another variable for writing our query like name, very close to name their close calling
equals in the right condition for query name.
He calls
single code class name plus double quotation mark and sits in your code between each.
And now in what multiple delete function from debate tools, package and send a student's instance,
experts argument and work lose a second argument for the condition in which rows affected.
So first define the variable like rows column equals in calling multiple delete function from TBE tools,
DV tools, dot multiple delete function sit model that a student as first argument.
And never close as second argument.
Now display return type as role variable FP
roles perfected and set rules variable, reformat the code and save the project before or on the program,
go to the database and see the name and age values of the records whose name is key.
OK, we can see names of the record by the I.D. number four and seven is gene.
Go to a school program and execute the project.
Go wrong.
That's practice.
Let me and name that go.
Now we can see the output rose affected to now go to the database again and execute, select, query
and see the changes execute the select query.
OK, now we can see that the records from the student table, whose name values are based on the value
of the very close condition have been removed from the student table.
The records by the I.D. number four and seven has removed from a student table.
Now go back to the school day and continue, but define another condition as very close arguments.
Consider that we want to delete students based on their ages, so define the concept based age, define
a variable like age.
And we want to say that every record whose age has this value.
First, we are the last cohort.
Defining a variable like age calling equals, for example, 20 and sit another variable for writing
our query like age workloads a year.
Plus, calling equals right conditions for query age equals.
We use this command to convert type of age from integer to string value and paste in it to the continuation
of our Estrange Plus.
It's all calm.
Don't I t or a and sit Ajaz argument and now invoked multiple delete function from debate rules package
and sit a student object as a first argument and a very close second argument for the condition and
fish rules affected?
So first define a variable like rose colored equals and cunning multiple delete functions from debate
tools, package TV tools dot multiple.
Let's set a student as argument model, dot student and set age work laws air conditioner.
And now display return type as role variable FP.
Rose affected me and said Rose valiantly reformat the cold and save the project before around the program,
go to the database and see.
Name and age values off the records whose ages 20.
Now we can see the student table ages of the record by the I.D. number three and ID number six are twenty.
Go back to the school program and execute the project, go wrong.
Back is this main and main the clue?
Now we can see the output rose affected to now go to database again and execute search query and see
the changes.
Now we can see that recourse from the student table, whose age values are based on the value of the
age, very close condition have been removed from the student table.
So I.D. number three and I.D. number six removed from a student table.
Okay.
In this chapter, we were able to implement crowd operations in the minuscule database via go programming
language using the Gouffran framework.
One of the highlights of this part of the tutorial was that we were able to design a separate package
as DV tools to connect to the database that is not depend on a specific estimate and can receive any
type of instrument to perform current operations like student contact information or to others this
us.
In other words, we were able to create a generator to perform crowd operations, and it has the ability
to send any specific as strong as the input parameters for our crowd methods.
Now we have reached the end of this session.
I hope you have taken full advantage of decision until the next session.
Goodbye.