1 00:00:11,940 --> 00:00:17,610 Hello and welcome to the Golang programming language course in the previous session, U.S. we could 2 00:00:17,610 --> 00:00:25,020 define a single delete function, and in this session we want to define the function name the multiple 3 00:00:25,020 --> 00:00:27,750 delete that accept two parameters. 4 00:00:28,230 --> 00:00:34,740 First parameter is an end to interface, which indicates that any instance of a strike is to be passed 5 00:00:34,740 --> 00:00:35,520 to dismantle. 6 00:00:36,000 --> 00:00:39,180 And second is a very closed string for condition. 7 00:00:39,420 --> 00:00:46,080 Also, dysfunction returns the number of records that have been affected by the delete operation at 8 00:00:46,080 --> 00:00:47,220 the end of the warps. 9 00:00:48,090 --> 00:00:52,380 So go to the DB connection and define our function. 10 00:00:57,150 --> 00:00:57,750 Fine. 11 00:00:59,350 --> 00:01:13,180 Multiple delete set a name like object as any either face object and in the interface 12 00:01:16,480 --> 00:01:18,940 sit very close as string as condition. 13 00:01:21,370 --> 00:01:32,530 Yeah, close by the time this string is condition and set in, 64 has returned, typed in 64. 14 00:01:35,330 --> 00:01:42,500 Now calling connect function for initializing MySchool data source name, this function returns a DV 15 00:01:42,530 --> 00:01:49,650 object from Gore package, which gives us access to matters contained in that package to perform current 16 00:01:49,700 --> 00:01:50,270 operation. 17 00:01:50,720 --> 00:01:56,660 So first, define a variable like DV call and equals end calling connect function. 18 00:01:58,850 --> 00:02:05,690 After creating a deep object from gore and package in what their function and set were, close object 19 00:02:05,690 --> 00:02:06,760 is an argument. 20 00:02:06,890 --> 00:02:09,380 Eat their function at conditions. 21 00:02:09,410 --> 00:02:14,990 So first, define it a bit like resolved Colin equals. 22 00:02:16,540 --> 00:02:21,190 And calling their function on the TV, RG dance, they're. 23 00:02:24,470 --> 00:02:27,440 And set very close a single object as arguments. 24 00:02:30,730 --> 00:02:37,360 And the more the invoked delete function, so we'll be calling delete functions from the object insert 25 00:02:37,360 --> 00:02:40,210 object instance as argument to it. 26 00:02:41,690 --> 00:02:43,880 Don't left 27 00:02:46,880 --> 00:02:56,930 and set object argument, delete function did its value much given conditions, then delete a record 28 00:02:56,960 --> 00:03:03,710 you need to ensure its primary field has value and gore and will use the primary key to delete the record. 29 00:03:03,770 --> 00:03:10,670 If primary fields blank or invalid, delete are records for the mother now invoking those affected field 30 00:03:10,670 --> 00:03:19,190 from resolved return that we showed the remove affected records or we write return result that rules 31 00:03:19,190 --> 00:03:22,850 affected reformat the code and save the project. 32 00:03:23,570 --> 00:03:29,470 We have now succeeded in designing a method to receive airstrike instance from the outside at delete 33 00:03:29,480 --> 00:03:32,030 this object from its table in the database. 34 00:03:33,470 --> 00:03:40,880 Now we go to the main function to use this query statement first to the last code. 35 00:03:46,130 --> 00:03:52,420 In this case, we want to delete all the students who have a special condition in the database, so 36 00:03:52,430 --> 00:03:56,030 we should use from multiple delete function from DV tools. 37 00:03:56,660 --> 00:04:00,110 First, define a condition as very close argument. 38 00:04:00,530 --> 00:04:07,300 Consider that we want to delete a student based on their names, so define the condition based NE. 39 00:04:08,210 --> 00:04:09,920 Define a variable like name. 40 00:04:09,920 --> 00:04:18,500 And we want to say that every record whose name has this value, for example, and name calling equals 41 00:04:19,310 --> 00:04:32,660 team and set another variable for writing our query like name, very close to name their close calling 42 00:04:34,220 --> 00:04:39,570 equals in the right condition for query name. 43 00:04:41,840 --> 00:04:42,620 He calls 44 00:04:45,710 --> 00:04:55,610 single code class name plus double quotation mark and sits in your code between each. 45 00:04:57,590 --> 00:05:04,570 And now in what multiple delete function from debate tools, package and send a student's instance, 46 00:05:04,600 --> 00:05:11,240 experts argument and work lose a second argument for the condition in which rows affected. 47 00:05:11,810 --> 00:05:21,080 So first define the variable like rows column equals in calling multiple delete function from TBE tools, 48 00:05:22,340 --> 00:05:32,420 DV tools, dot multiple delete function sit model that a student as first argument. 49 00:05:34,030 --> 00:05:37,780 And never close as second argument. 50 00:05:40,620 --> 00:05:45,120 Now display return type as role variable FP 51 00:05:49,020 --> 00:06:02,100 roles perfected and set rules variable, reformat the code and save the project before or on the program, 52 00:06:02,100 --> 00:06:08,280 go to the database and see the name and age values of the records whose name is key. 53 00:06:09,280 --> 00:06:18,330 OK, we can see names of the record by the I.D. number four and seven is gene. 54 00:06:19,860 --> 00:06:23,130 Go to a school program and execute the project. 55 00:06:24,180 --> 00:06:25,710 Go wrong. 56 00:06:25,810 --> 00:06:26,610 That's practice. 57 00:06:26,610 --> 00:06:30,480 Let me and name that go. 58 00:06:34,500 --> 00:06:42,630 Now we can see the output rose affected to now go to the database again and execute, select, query 59 00:06:42,630 --> 00:06:46,410 and see the changes execute the select query. 60 00:06:49,010 --> 00:06:56,750 OK, now we can see that the records from the student table, whose name values are based on the value 61 00:06:56,750 --> 00:07:01,100 of the very close condition have been removed from the student table. 62 00:07:01,820 --> 00:07:07,610 The records by the I.D. number four and seven has removed from a student table. 63 00:07:07,730 --> 00:07:14,090 Now go back to the school day and continue, but define another condition as very close arguments. 64 00:07:14,090 --> 00:07:21,530 Consider that we want to delete students based on their ages, so define the concept based age, define 65 00:07:21,590 --> 00:07:22,940 a variable like age. 66 00:07:22,940 --> 00:07:26,330 And we want to say that every record whose age has this value. 67 00:07:26,720 --> 00:07:28,490 First, we are the last cohort. 68 00:07:32,990 --> 00:07:41,270 Defining a variable like age calling equals, for example, 20 and sit another variable for writing 69 00:07:41,270 --> 00:07:46,470 our query like age workloads a year. 70 00:07:47,870 --> 00:07:57,950 Plus, calling equals right conditions for query age equals. 71 00:07:58,130 --> 00:08:05,900 We use this command to convert type of age from integer to string value and paste in it to the continuation 72 00:08:05,900 --> 00:08:08,870 of our Estrange Plus. 73 00:08:10,010 --> 00:08:11,780 It's all calm. 74 00:08:14,240 --> 00:08:26,150 Don't I t or a and sit Ajaz argument and now invoked multiple delete function from debate rules package 75 00:08:26,510 --> 00:08:34,310 and sit a student object as a first argument and a very close second argument for the condition and 76 00:08:34,310 --> 00:08:35,900 fish rules affected? 77 00:08:35,900 --> 00:08:43,270 So first define a variable like rose colored equals and cunning multiple delete functions from debate 78 00:08:43,280 --> 00:08:48,230 tools, package TV tools dot multiple. 79 00:08:48,820 --> 00:09:00,050 Let's set a student as argument model, dot student and set age work laws air conditioner. 80 00:09:05,270 --> 00:09:09,410 And now display return type as role variable FP. 81 00:09:11,720 --> 00:09:23,990 Rose affected me and said Rose valiantly reformat the cold and save the project before around the program, 82 00:09:23,990 --> 00:09:26,330 go to the database and see. 83 00:09:26,360 --> 00:09:30,920 Name and age values off the records whose ages 20. 84 00:09:31,610 --> 00:09:42,440 Now we can see the student table ages of the record by the I.D. number three and ID number six are twenty. 85 00:09:43,890 --> 00:09:51,020 Go back to the school program and execute the project, go wrong. 86 00:09:51,360 --> 00:09:54,900 Back is this main and main the clue? 87 00:09:59,090 --> 00:10:07,100 Now we can see the output rose affected to now go to database again and execute search query and see 88 00:10:07,100 --> 00:10:07,820 the changes. 89 00:10:11,790 --> 00:10:17,880 Now we can see that recourse from the student table, whose age values are based on the value of the 90 00:10:18,090 --> 00:10:22,380 age, very close condition have been removed from the student table. 91 00:10:23,220 --> 00:10:28,780 So I.D. number three and I.D. number six removed from a student table. 92 00:10:29,820 --> 00:10:30,230 Okay. 93 00:10:30,720 --> 00:10:37,800 In this chapter, we were able to implement crowd operations in the minuscule database via go programming 94 00:10:37,800 --> 00:10:40,560 language using the Gouffran framework. 95 00:10:41,460 --> 00:10:48,060 One of the highlights of this part of the tutorial was that we were able to design a separate package 96 00:10:48,060 --> 00:10:55,500 as DV tools to connect to the database that is not depend on a specific estimate and can receive any 97 00:10:55,500 --> 00:11:01,350 type of instrument to perform current operations like student contact information or to others this 98 00:11:01,500 --> 00:11:01,790 us. 99 00:11:02,250 --> 00:11:09,210 In other words, we were able to create a generator to perform crowd operations, and it has the ability 100 00:11:09,210 --> 00:11:14,130 to send any specific as strong as the input parameters for our crowd methods. 101 00:11:15,330 --> 00:11:17,460 Now we have reached the end of this session. 102 00:11:17,670 --> 00:11:21,650 I hope you have taken full advantage of decision until the next session. 103 00:11:21,720 --> 00:11:22,320 Goodbye.