github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/core/rawdata/scans.go (about) 1 // DON'T EDIT - automatically generated by structgen // 2 3 package rawdata 4 5 import ( 6 "database/sql" 7 8 "github.com/lib/pq" 9 ) 10 11 type scanner interface { 12 Scan(...interface{}) error 13 } 14 15 // DB groups transaction like objects 16 type DB interface { 17 Exec(query string, args ...interface{}) (sql.Result, error) 18 Query(query string, args ...interface{}) (*sql.Rows, error) 19 QueryRow(query string, args ...interface{}) *sql.Row 20 Prepare(query string) (*sql.Stmt, error) 21 } 22 23 func scanOneAide(row scanner) (Aide, error) { 24 var s Aide 25 err := row.Scan( 26 &s.Id, 27 &s.IdStructureaide, 28 &s.IdParticipant, 29 &s.Valeur, 30 &s.Valide, 31 &s.ParJour, 32 &s.NbJoursMax, 33 ) 34 return s, err 35 } 36 37 func ScanAide(row *sql.Row) (Aide, error) { 38 return scanOneAide(row) 39 } 40 41 func SelectAllAides(tx DB) (Aides, error) { 42 rows, err := tx.Query("SELECT * FROM aides") 43 if err != nil { 44 return nil, err 45 } 46 return ScanAides(rows) 47 } 48 49 // SelectAide returns the entry matching id. 50 func SelectAide(tx DB, id int64) (Aide, error) { 51 row := tx.QueryRow("SELECT * FROM aides WHERE id = $1", id) 52 return ScanAide(row) 53 } 54 55 // SelectAides returns the entry matching the given ids. 56 func SelectAides(tx DB, ids ...int64) (Aides, error) { 57 rows, err := tx.Query("SELECT * FROM aides WHERE id = ANY($1)", pq.Int64Array(ids)) 58 if err != nil { 59 return nil, err 60 } 61 return ScanAides(rows) 62 } 63 64 type Aides map[int64]Aide 65 66 func (m Aides) Ids() Ids { 67 out := make(Ids, 0, len(m)) 68 for i := range m { 69 out = append(out, i) 70 } 71 return out 72 } 73 74 func ScanAides(rs *sql.Rows) (Aides, error) { 75 var ( 76 s Aide 77 err error 78 ) 79 defer func() { 80 errClose := rs.Close() 81 if err == nil { 82 err = errClose 83 } 84 }() 85 structs := make(Aides, 16) 86 for rs.Next() { 87 s, err = scanOneAide(rs) 88 if err != nil { 89 return nil, err 90 } 91 structs[s.Id] = s 92 } 93 if err = rs.Err(); err != nil { 94 return nil, err 95 } 96 return structs, nil 97 } 98 99 // Insert Aide in the database and returns the item with id filled. 100 func (item Aide) Insert(tx DB) (out Aide, err error) { 101 row := tx.QueryRow(`INSERT INTO aides ( 102 id_structureaide,id_participant,valeur,valide,par_jour,nb_jours_max 103 ) VALUES ( 104 $1,$2,$3,$4,$5,$6 105 ) RETURNING 106 id,id_structureaide,id_participant,valeur,valide,par_jour,nb_jours_max; 107 `, item.IdStructureaide, item.IdParticipant, item.Valeur, item.Valide, item.ParJour, item.NbJoursMax) 108 return ScanAide(row) 109 } 110 111 // Update Aide in the database and returns the new version. 112 func (item Aide) Update(tx DB) (out Aide, err error) { 113 row := tx.QueryRow(`UPDATE aides SET ( 114 id_structureaide,id_participant,valeur,valide,par_jour,nb_jours_max 115 ) = ( 116 $2,$3,$4,$5,$6,$7 117 ) WHERE id = $1 RETURNING 118 id,id_structureaide,id_participant,valeur,valide,par_jour,nb_jours_max; 119 `, item.Id, item.IdStructureaide, item.IdParticipant, item.Valeur, item.Valide, item.ParJour, item.NbJoursMax) 120 return ScanAide(row) 121 } 122 123 // Deletes the Aide and returns the item 124 func DeleteAideById(tx DB, id int64) (Aide, error) { 125 row := tx.QueryRow("DELETE FROM aides WHERE id = $1 RETURNING *;", id) 126 return ScanAide(row) 127 } 128 129 // Deletes the Aide in the database and returns the ids. 130 func DeleteAidesByIds(tx DB, ids ...int64) (Ids, error) { 131 rows, err := tx.Query("DELETE FROM aides WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 132 if err != nil { 133 return nil, err 134 } 135 return ScanIds(rows) 136 } 137 138 func scanOneCamp(row scanner) (Camp, error) { 139 var s Camp 140 err := row.Scan( 141 &s.Id, 142 &s.Lieu, 143 &s.Nom, 144 &s.Prix, 145 &s.NbPlaces, 146 &s.Password, 147 &s.Ouvert, 148 &s.NbPlacesReservees, 149 &s.NumeroJS, 150 &s.NeedEquilibreGf, 151 &s.AgeMin, 152 &s.AgeMax, 153 &s.Options, 154 &s.DateDebut, 155 &s.DateFin, 156 &s.ListeVetements, 157 &s.SchemaPaiement, 158 &s.JoomeoAlbumId, 159 &s.Envois, 160 &s.LienCompta, 161 &s.OptionPrix, 162 &s.InscriptionSimple, 163 &s.Infos, 164 ) 165 return s, err 166 } 167 168 func ScanCamp(row *sql.Row) (Camp, error) { 169 return scanOneCamp(row) 170 } 171 172 func SelectAllCamps(tx DB) (Camps, error) { 173 rows, err := tx.Query("SELECT * FROM camps") 174 if err != nil { 175 return nil, err 176 } 177 return ScanCamps(rows) 178 } 179 180 // SelectCamp returns the entry matching id. 181 func SelectCamp(tx DB, id int64) (Camp, error) { 182 row := tx.QueryRow("SELECT * FROM camps WHERE id = $1", id) 183 return ScanCamp(row) 184 } 185 186 // SelectCamps returns the entry matching the given ids. 187 func SelectCamps(tx DB, ids ...int64) (Camps, error) { 188 rows, err := tx.Query("SELECT * FROM camps WHERE id = ANY($1)", pq.Int64Array(ids)) 189 if err != nil { 190 return nil, err 191 } 192 return ScanCamps(rows) 193 } 194 195 type Camps map[int64]Camp 196 197 func (m Camps) Ids() Ids { 198 out := make(Ids, 0, len(m)) 199 for i := range m { 200 out = append(out, i) 201 } 202 return out 203 } 204 205 func ScanCamps(rs *sql.Rows) (Camps, error) { 206 var ( 207 s Camp 208 err error 209 ) 210 defer func() { 211 errClose := rs.Close() 212 if err == nil { 213 err = errClose 214 } 215 }() 216 structs := make(Camps, 16) 217 for rs.Next() { 218 s, err = scanOneCamp(rs) 219 if err != nil { 220 return nil, err 221 } 222 structs[s.Id] = s 223 } 224 if err = rs.Err(); err != nil { 225 return nil, err 226 } 227 return structs, nil 228 } 229 230 // Insert Camp in the database and returns the item with id filled. 231 func (item Camp) Insert(tx DB) (out Camp, err error) { 232 row := tx.QueryRow(`INSERT INTO camps ( 233 lieu,nom,prix,nb_places,password,ouvert,nb_places_reservees,numero_js,need_equilibre_gf,age_min,age_max,options,date_debut,date_fin,liste_vetements,schema_paiement,joomeo_album_id,envois,lien_compta,option_prix,inscription_simple,infos 234 ) VALUES ( 235 $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22 236 ) RETURNING 237 id,lieu,nom,prix,nb_places,password,ouvert,nb_places_reservees,numero_js,need_equilibre_gf,age_min,age_max,options,date_debut,date_fin,liste_vetements,schema_paiement,joomeo_album_id,envois,lien_compta,option_prix,inscription_simple,infos; 238 `, item.Lieu, item.Nom, item.Prix, item.NbPlaces, item.Password, item.Ouvert, item.NbPlacesReservees, item.NumeroJS, item.NeedEquilibreGf, item.AgeMin, item.AgeMax, item.Options, item.DateDebut, item.DateFin, item.ListeVetements, item.SchemaPaiement, item.JoomeoAlbumId, item.Envois, item.LienCompta, item.OptionPrix, item.InscriptionSimple, item.Infos) 239 return ScanCamp(row) 240 } 241 242 // Update Camp in the database and returns the new version. 243 func (item Camp) Update(tx DB) (out Camp, err error) { 244 row := tx.QueryRow(`UPDATE camps SET ( 245 lieu,nom,prix,nb_places,password,ouvert,nb_places_reservees,numero_js,need_equilibre_gf,age_min,age_max,options,date_debut,date_fin,liste_vetements,schema_paiement,joomeo_album_id,envois,lien_compta,option_prix,inscription_simple,infos 246 ) = ( 247 $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23 248 ) WHERE id = $1 RETURNING 249 id,lieu,nom,prix,nb_places,password,ouvert,nb_places_reservees,numero_js,need_equilibre_gf,age_min,age_max,options,date_debut,date_fin,liste_vetements,schema_paiement,joomeo_album_id,envois,lien_compta,option_prix,inscription_simple,infos; 250 `, item.Id, item.Lieu, item.Nom, item.Prix, item.NbPlaces, item.Password, item.Ouvert, item.NbPlacesReservees, item.NumeroJS, item.NeedEquilibreGf, item.AgeMin, item.AgeMax, item.Options, item.DateDebut, item.DateFin, item.ListeVetements, item.SchemaPaiement, item.JoomeoAlbumId, item.Envois, item.LienCompta, item.OptionPrix, item.InscriptionSimple, item.Infos) 251 return ScanCamp(row) 252 } 253 254 // Deletes the Camp and returns the item 255 func DeleteCampById(tx DB, id int64) (Camp, error) { 256 row := tx.QueryRow("DELETE FROM camps WHERE id = $1 RETURNING *;", id) 257 return ScanCamp(row) 258 } 259 260 // Deletes the Camp in the database and returns the ids. 261 func DeleteCampsByIds(tx DB, ids ...int64) (Ids, error) { 262 rows, err := tx.Query("DELETE FROM camps WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 263 if err != nil { 264 return nil, err 265 } 266 return ScanIds(rows) 267 } 268 269 func scanOneCampContrainte(row scanner) (CampContrainte, error) { 270 var s CampContrainte 271 err := row.Scan( 272 &s.IdCamp, 273 &s.IdContrainte, 274 ) 275 return s, err 276 } 277 278 func ScanCampContrainte(row *sql.Row) (CampContrainte, error) { 279 return scanOneCampContrainte(row) 280 } 281 282 func SelectAllCampContraintes(tx DB) (CampContraintes, error) { 283 rows, err := tx.Query("SELECT * FROM camp_contraintes") 284 if err != nil { 285 return nil, err 286 } 287 return ScanCampContraintes(rows) 288 } 289 290 type CampContraintes []CampContrainte 291 292 func ScanCampContraintes(rs *sql.Rows) (CampContraintes, error) { 293 var ( 294 s CampContrainte 295 err error 296 ) 297 defer func() { 298 errClose := rs.Close() 299 if err == nil { 300 err = errClose 301 } 302 }() 303 structs := make(CampContraintes, 0, 16) 304 for rs.Next() { 305 s, err = scanOneCampContrainte(rs) 306 if err != nil { 307 return nil, err 308 } 309 structs = append(structs, s) 310 } 311 if err = rs.Err(); err != nil { 312 return nil, err 313 } 314 return structs, nil 315 } 316 317 // Insert the links CampContrainte in the database. 318 func InsertManyCampContraintes(tx *sql.Tx, items ...CampContrainte) error { 319 if len(items) == 0 { 320 return nil 321 } 322 323 stmt, err := tx.Prepare(pq.CopyIn("camp_contraintes", 324 "id_camp", "id_contrainte", 325 )) 326 if err != nil { 327 return err 328 } 329 330 for _, item := range items { 331 _, err = stmt.Exec(item.IdCamp, item.IdContrainte) 332 if err != nil { 333 return err 334 } 335 } 336 337 if _, err = stmt.Exec(); err != nil { 338 return err 339 } 340 341 if err = stmt.Close(); err != nil { 342 return err 343 } 344 return nil 345 } 346 347 // Delete the link CampContrainte in the database. 348 // Only the 'IdCamp' 'IdContrainte' fields are used. 349 func (item CampContrainte) Delete(tx DB) error { 350 _, err := tx.Exec(`DELETE FROM camp_contraintes WHERE 351 id_camp = $1 AND id_contrainte = $2;`, item.IdCamp, item.IdContrainte) 352 return err 353 } 354 355 func scanOneContenuDocument(row scanner) (ContenuDocument, error) { 356 var s ContenuDocument 357 err := row.Scan( 358 &s.IdDocument, 359 &s.Contenu, 360 &s.Miniature, 361 ) 362 return s, err 363 } 364 365 func ScanContenuDocument(row *sql.Row) (ContenuDocument, error) { 366 return scanOneContenuDocument(row) 367 } 368 369 func SelectAllContenuDocuments(tx DB) (ContenuDocuments, error) { 370 rows, err := tx.Query("SELECT * FROM contenu_documents") 371 if err != nil { 372 return nil, err 373 } 374 return ScanContenuDocuments(rows) 375 } 376 377 type ContenuDocuments []ContenuDocument 378 379 func ScanContenuDocuments(rs *sql.Rows) (ContenuDocuments, error) { 380 var ( 381 s ContenuDocument 382 err error 383 ) 384 defer func() { 385 errClose := rs.Close() 386 if err == nil { 387 err = errClose 388 } 389 }() 390 structs := make(ContenuDocuments, 0, 16) 391 for rs.Next() { 392 s, err = scanOneContenuDocument(rs) 393 if err != nil { 394 return nil, err 395 } 396 structs = append(structs, s) 397 } 398 if err = rs.Err(); err != nil { 399 return nil, err 400 } 401 return structs, nil 402 } 403 404 // Insert the links ContenuDocument in the database. 405 func InsertManyContenuDocuments(tx *sql.Tx, items ...ContenuDocument) error { 406 if len(items) == 0 { 407 return nil 408 } 409 410 stmt, err := tx.Prepare(pq.CopyIn("contenu_documents", 411 "id_document", "contenu", "miniature", 412 )) 413 if err != nil { 414 return err 415 } 416 417 for _, item := range items { 418 _, err = stmt.Exec(item.IdDocument, item.Contenu, item.Miniature) 419 if err != nil { 420 return err 421 } 422 } 423 424 if _, err = stmt.Exec(); err != nil { 425 return err 426 } 427 428 if err = stmt.Close(); err != nil { 429 return err 430 } 431 return nil 432 } 433 434 // Delete the link ContenuDocument in the database. 435 // Only the 'IdDocument' fields are used. 436 func (item ContenuDocument) Delete(tx DB) error { 437 _, err := tx.Exec(`DELETE FROM contenu_documents WHERE 438 id_document = $1;`, item.IdDocument) 439 return err 440 } 441 442 func scanOneContrainte(row scanner) (Contrainte, error) { 443 var s Contrainte 444 err := row.Scan( 445 &s.Id, 446 &s.IdPersonne, 447 &s.IdDocument, 448 &s.Builtin, 449 &s.Nom, 450 &s.Description, 451 &s.MaxDocs, 452 &s.JoursValide, 453 ) 454 return s, err 455 } 456 457 func ScanContrainte(row *sql.Row) (Contrainte, error) { 458 return scanOneContrainte(row) 459 } 460 461 func SelectAllContraintes(tx DB) (Contraintes, error) { 462 rows, err := tx.Query("SELECT * FROM contraintes") 463 if err != nil { 464 return nil, err 465 } 466 return ScanContraintes(rows) 467 } 468 469 // SelectContrainte returns the entry matching id. 470 func SelectContrainte(tx DB, id int64) (Contrainte, error) { 471 row := tx.QueryRow("SELECT * FROM contraintes WHERE id = $1", id) 472 return ScanContrainte(row) 473 } 474 475 // SelectContraintes returns the entry matching the given ids. 476 func SelectContraintes(tx DB, ids ...int64) (Contraintes, error) { 477 rows, err := tx.Query("SELECT * FROM contraintes WHERE id = ANY($1)", pq.Int64Array(ids)) 478 if err != nil { 479 return nil, err 480 } 481 return ScanContraintes(rows) 482 } 483 484 type Contraintes map[int64]Contrainte 485 486 func (m Contraintes) Ids() Ids { 487 out := make(Ids, 0, len(m)) 488 for i := range m { 489 out = append(out, i) 490 } 491 return out 492 } 493 494 func ScanContraintes(rs *sql.Rows) (Contraintes, error) { 495 var ( 496 s Contrainte 497 err error 498 ) 499 defer func() { 500 errClose := rs.Close() 501 if err == nil { 502 err = errClose 503 } 504 }() 505 structs := make(Contraintes, 16) 506 for rs.Next() { 507 s, err = scanOneContrainte(rs) 508 if err != nil { 509 return nil, err 510 } 511 structs[s.Id] = s 512 } 513 if err = rs.Err(); err != nil { 514 return nil, err 515 } 516 return structs, nil 517 } 518 519 // Insert Contrainte in the database and returns the item with id filled. 520 func (item Contrainte) Insert(tx DB) (out Contrainte, err error) { 521 row := tx.QueryRow(`INSERT INTO contraintes ( 522 id_personne,id_document,builtin,nom,description,max_docs,jours_valide 523 ) VALUES ( 524 $1,$2,$3,$4,$5,$6,$7 525 ) RETURNING 526 id,id_personne,id_document,builtin,nom,description,max_docs,jours_valide; 527 `, item.IdPersonne, item.IdDocument, item.Builtin, item.Nom, item.Description, item.MaxDocs, item.JoursValide) 528 return ScanContrainte(row) 529 } 530 531 // Update Contrainte in the database and returns the new version. 532 func (item Contrainte) Update(tx DB) (out Contrainte, err error) { 533 row := tx.QueryRow(`UPDATE contraintes SET ( 534 id_personne,id_document,builtin,nom,description,max_docs,jours_valide 535 ) = ( 536 $2,$3,$4,$5,$6,$7,$8 537 ) WHERE id = $1 RETURNING 538 id,id_personne,id_document,builtin,nom,description,max_docs,jours_valide; 539 `, item.Id, item.IdPersonne, item.IdDocument, item.Builtin, item.Nom, item.Description, item.MaxDocs, item.JoursValide) 540 return ScanContrainte(row) 541 } 542 543 // Deletes the Contrainte and returns the item 544 func DeleteContrainteById(tx DB, id int64) (Contrainte, error) { 545 row := tx.QueryRow("DELETE FROM contraintes WHERE id = $1 RETURNING *;", id) 546 return ScanContrainte(row) 547 } 548 549 // Deletes the Contrainte in the database and returns the ids. 550 func DeleteContraintesByIds(tx DB, ids ...int64) (Ids, error) { 551 rows, err := tx.Query("DELETE FROM contraintes WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 552 if err != nil { 553 return nil, err 554 } 555 return ScanIds(rows) 556 } 557 558 func scanOneDocument(row scanner) (Document, error) { 559 var s Document 560 err := row.Scan( 561 &s.Id, 562 &s.Taille, 563 &s.NomClient, 564 &s.Description, 565 &s.DateHeureModif, 566 ) 567 return s, err 568 } 569 570 func ScanDocument(row *sql.Row) (Document, error) { 571 return scanOneDocument(row) 572 } 573 574 func SelectAllDocuments(tx DB) (Documents, error) { 575 rows, err := tx.Query("SELECT * FROM documents") 576 if err != nil { 577 return nil, err 578 } 579 return ScanDocuments(rows) 580 } 581 582 // SelectDocument returns the entry matching id. 583 func SelectDocument(tx DB, id int64) (Document, error) { 584 row := tx.QueryRow("SELECT * FROM documents WHERE id = $1", id) 585 return ScanDocument(row) 586 } 587 588 // SelectDocuments returns the entry matching the given ids. 589 func SelectDocuments(tx DB, ids ...int64) (Documents, error) { 590 rows, err := tx.Query("SELECT * FROM documents WHERE id = ANY($1)", pq.Int64Array(ids)) 591 if err != nil { 592 return nil, err 593 } 594 return ScanDocuments(rows) 595 } 596 597 type Documents map[int64]Document 598 599 func (m Documents) Ids() Ids { 600 out := make(Ids, 0, len(m)) 601 for i := range m { 602 out = append(out, i) 603 } 604 return out 605 } 606 607 func ScanDocuments(rs *sql.Rows) (Documents, error) { 608 var ( 609 s Document 610 err error 611 ) 612 defer func() { 613 errClose := rs.Close() 614 if err == nil { 615 err = errClose 616 } 617 }() 618 structs := make(Documents, 16) 619 for rs.Next() { 620 s, err = scanOneDocument(rs) 621 if err != nil { 622 return nil, err 623 } 624 structs[s.Id] = s 625 } 626 if err = rs.Err(); err != nil { 627 return nil, err 628 } 629 return structs, nil 630 } 631 632 // Insert Document in the database and returns the item with id filled. 633 func (item Document) Insert(tx DB) (out Document, err error) { 634 row := tx.QueryRow(`INSERT INTO documents ( 635 taille,nom_client,description,date_heure_modif 636 ) VALUES ( 637 $1,$2,$3,$4 638 ) RETURNING 639 id,taille,nom_client,description,date_heure_modif; 640 `, item.Taille, item.NomClient, item.Description, item.DateHeureModif) 641 return ScanDocument(row) 642 } 643 644 // Update Document in the database and returns the new version. 645 func (item Document) Update(tx DB) (out Document, err error) { 646 row := tx.QueryRow(`UPDATE documents SET ( 647 taille,nom_client,description,date_heure_modif 648 ) = ( 649 $2,$3,$4,$5 650 ) WHERE id = $1 RETURNING 651 id,taille,nom_client,description,date_heure_modif; 652 `, item.Id, item.Taille, item.NomClient, item.Description, item.DateHeureModif) 653 return ScanDocument(row) 654 } 655 656 // Deletes the Document and returns the item 657 func DeleteDocumentById(tx DB, id int64) (Document, error) { 658 row := tx.QueryRow("DELETE FROM documents WHERE id = $1 RETURNING *;", id) 659 return ScanDocument(row) 660 } 661 662 // Deletes the Document in the database and returns the ids. 663 func DeleteDocumentsByIds(tx DB, ids ...int64) (Ids, error) { 664 rows, err := tx.Query("DELETE FROM documents WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 665 if err != nil { 666 return nil, err 667 } 668 return ScanIds(rows) 669 } 670 671 func scanOneDocumentAide(row scanner) (DocumentAide, error) { 672 var s DocumentAide 673 err := row.Scan( 674 &s.IdDocument, 675 &s.IdAide, 676 ) 677 return s, err 678 } 679 680 func ScanDocumentAide(row *sql.Row) (DocumentAide, error) { 681 return scanOneDocumentAide(row) 682 } 683 684 func SelectAllDocumentAides(tx DB) (DocumentAides, error) { 685 rows, err := tx.Query("SELECT * FROM document_aides") 686 if err != nil { 687 return nil, err 688 } 689 return ScanDocumentAides(rows) 690 } 691 692 type DocumentAides []DocumentAide 693 694 func ScanDocumentAides(rs *sql.Rows) (DocumentAides, error) { 695 var ( 696 s DocumentAide 697 err error 698 ) 699 defer func() { 700 errClose := rs.Close() 701 if err == nil { 702 err = errClose 703 } 704 }() 705 structs := make(DocumentAides, 0, 16) 706 for rs.Next() { 707 s, err = scanOneDocumentAide(rs) 708 if err != nil { 709 return nil, err 710 } 711 structs = append(structs, s) 712 } 713 if err = rs.Err(); err != nil { 714 return nil, err 715 } 716 return structs, nil 717 } 718 719 // Insert the links DocumentAide in the database. 720 func InsertManyDocumentAides(tx *sql.Tx, items ...DocumentAide) error { 721 if len(items) == 0 { 722 return nil 723 } 724 725 stmt, err := tx.Prepare(pq.CopyIn("document_aides", 726 "id_document", "id_aide", 727 )) 728 if err != nil { 729 return err 730 } 731 732 for _, item := range items { 733 _, err = stmt.Exec(item.IdDocument, item.IdAide) 734 if err != nil { 735 return err 736 } 737 } 738 739 if _, err = stmt.Exec(); err != nil { 740 return err 741 } 742 743 if err = stmt.Close(); err != nil { 744 return err 745 } 746 return nil 747 } 748 749 // Delete the link DocumentAide in the database. 750 // Only the 'IdDocument' 'IdAide' fields are used. 751 func (item DocumentAide) Delete(tx DB) error { 752 _, err := tx.Exec(`DELETE FROM document_aides WHERE 753 id_document = $1 AND id_aide = $2;`, item.IdDocument, item.IdAide) 754 return err 755 } 756 757 func scanOneDocumentCamp(row scanner) (DocumentCamp, error) { 758 var s DocumentCamp 759 err := row.Scan( 760 &s.IdDocument, 761 &s.IdCamp, 762 &s.IsLettre, 763 ) 764 return s, err 765 } 766 767 func ScanDocumentCamp(row *sql.Row) (DocumentCamp, error) { 768 return scanOneDocumentCamp(row) 769 } 770 771 func SelectAllDocumentCamps(tx DB) (DocumentCamps, error) { 772 rows, err := tx.Query("SELECT * FROM document_camps") 773 if err != nil { 774 return nil, err 775 } 776 return ScanDocumentCamps(rows) 777 } 778 779 type DocumentCamps []DocumentCamp 780 781 func ScanDocumentCamps(rs *sql.Rows) (DocumentCamps, error) { 782 var ( 783 s DocumentCamp 784 err error 785 ) 786 defer func() { 787 errClose := rs.Close() 788 if err == nil { 789 err = errClose 790 } 791 }() 792 structs := make(DocumentCamps, 0, 16) 793 for rs.Next() { 794 s, err = scanOneDocumentCamp(rs) 795 if err != nil { 796 return nil, err 797 } 798 structs = append(structs, s) 799 } 800 if err = rs.Err(); err != nil { 801 return nil, err 802 } 803 return structs, nil 804 } 805 806 // Insert the links DocumentCamp in the database. 807 func InsertManyDocumentCamps(tx *sql.Tx, items ...DocumentCamp) error { 808 if len(items) == 0 { 809 return nil 810 } 811 812 stmt, err := tx.Prepare(pq.CopyIn("document_camps", 813 "id_document", "id_camp", "is_lettre", 814 )) 815 if err != nil { 816 return err 817 } 818 819 for _, item := range items { 820 _, err = stmt.Exec(item.IdDocument, item.IdCamp, item.IsLettre) 821 if err != nil { 822 return err 823 } 824 } 825 826 if _, err = stmt.Exec(); err != nil { 827 return err 828 } 829 830 if err = stmt.Close(); err != nil { 831 return err 832 } 833 return nil 834 } 835 836 // Delete the link DocumentCamp in the database. 837 // Only the 'IdDocument' 'IdCamp' fields are used. 838 func (item DocumentCamp) Delete(tx DB) error { 839 _, err := tx.Exec(`DELETE FROM document_camps WHERE 840 id_document = $1 AND id_camp = $2;`, item.IdDocument, item.IdCamp) 841 return err 842 } 843 844 func scanOneDocumentPersonne(row scanner) (DocumentPersonne, error) { 845 var s DocumentPersonne 846 err := row.Scan( 847 &s.IdDocument, 848 &s.IdPersonne, 849 &s.IdContrainte, 850 ) 851 return s, err 852 } 853 854 func ScanDocumentPersonne(row *sql.Row) (DocumentPersonne, error) { 855 return scanOneDocumentPersonne(row) 856 } 857 858 func SelectAllDocumentPersonnes(tx DB) (DocumentPersonnes, error) { 859 rows, err := tx.Query("SELECT * FROM document_personnes") 860 if err != nil { 861 return nil, err 862 } 863 return ScanDocumentPersonnes(rows) 864 } 865 866 type DocumentPersonnes []DocumentPersonne 867 868 func ScanDocumentPersonnes(rs *sql.Rows) (DocumentPersonnes, error) { 869 var ( 870 s DocumentPersonne 871 err error 872 ) 873 defer func() { 874 errClose := rs.Close() 875 if err == nil { 876 err = errClose 877 } 878 }() 879 structs := make(DocumentPersonnes, 0, 16) 880 for rs.Next() { 881 s, err = scanOneDocumentPersonne(rs) 882 if err != nil { 883 return nil, err 884 } 885 structs = append(structs, s) 886 } 887 if err = rs.Err(); err != nil { 888 return nil, err 889 } 890 return structs, nil 891 } 892 893 // Insert the links DocumentPersonne in the database. 894 func InsertManyDocumentPersonnes(tx *sql.Tx, items ...DocumentPersonne) error { 895 if len(items) == 0 { 896 return nil 897 } 898 899 stmt, err := tx.Prepare(pq.CopyIn("document_personnes", 900 "id_document", "id_personne", "id_contrainte", 901 )) 902 if err != nil { 903 return err 904 } 905 906 for _, item := range items { 907 _, err = stmt.Exec(item.IdDocument, item.IdPersonne, item.IdContrainte) 908 if err != nil { 909 return err 910 } 911 } 912 913 if _, err = stmt.Exec(); err != nil { 914 return err 915 } 916 917 if err = stmt.Close(); err != nil { 918 return err 919 } 920 return nil 921 } 922 923 // Delete the link DocumentPersonne in the database. 924 // Only the 'IdDocument' 'IdPersonne' 'IdContrainte' fields are used. 925 func (item DocumentPersonne) Delete(tx DB) error { 926 _, err := tx.Exec(`DELETE FROM document_personnes WHERE 927 id_document = $1 AND id_personne = $2 AND id_contrainte = $3;`, item.IdDocument, item.IdPersonne, item.IdContrainte) 928 return err 929 } 930 931 func scanOneDon(row scanner) (Don, error) { 932 var s Don 933 err := row.Scan( 934 &s.Id, 935 &s.Valeur, 936 &s.ModePaiement, 937 &s.DateReception, 938 &s.RecuEmis, 939 &s.Infos, 940 &s.Remercie, 941 &s.Details, 942 &s.Affectation, 943 ) 944 return s, err 945 } 946 947 func ScanDon(row *sql.Row) (Don, error) { 948 return scanOneDon(row) 949 } 950 951 func SelectAllDons(tx DB) (Dons, error) { 952 rows, err := tx.Query("SELECT * FROM dons") 953 if err != nil { 954 return nil, err 955 } 956 return ScanDons(rows) 957 } 958 959 // SelectDon returns the entry matching id. 960 func SelectDon(tx DB, id int64) (Don, error) { 961 row := tx.QueryRow("SELECT * FROM dons WHERE id = $1", id) 962 return ScanDon(row) 963 } 964 965 // SelectDons returns the entry matching the given ids. 966 func SelectDons(tx DB, ids ...int64) (Dons, error) { 967 rows, err := tx.Query("SELECT * FROM dons WHERE id = ANY($1)", pq.Int64Array(ids)) 968 if err != nil { 969 return nil, err 970 } 971 return ScanDons(rows) 972 } 973 974 type Dons map[int64]Don 975 976 func (m Dons) Ids() Ids { 977 out := make(Ids, 0, len(m)) 978 for i := range m { 979 out = append(out, i) 980 } 981 return out 982 } 983 984 func ScanDons(rs *sql.Rows) (Dons, error) { 985 var ( 986 s Don 987 err error 988 ) 989 defer func() { 990 errClose := rs.Close() 991 if err == nil { 992 err = errClose 993 } 994 }() 995 structs := make(Dons, 16) 996 for rs.Next() { 997 s, err = scanOneDon(rs) 998 if err != nil { 999 return nil, err 1000 } 1001 structs[s.Id] = s 1002 } 1003 if err = rs.Err(); err != nil { 1004 return nil, err 1005 } 1006 return structs, nil 1007 } 1008 1009 // Insert Don in the database and returns the item with id filled. 1010 func (item Don) Insert(tx DB) (out Don, err error) { 1011 row := tx.QueryRow(`INSERT INTO dons ( 1012 valeur,mode_paiement,date_reception,recu_emis,infos,remercie,details,affectation 1013 ) VALUES ( 1014 $1,$2,$3,$4,$5,$6,$7,$8 1015 ) RETURNING 1016 id,valeur,mode_paiement,date_reception,recu_emis,infos,remercie,details,affectation; 1017 `, item.Valeur, item.ModePaiement, item.DateReception, item.RecuEmis, item.Infos, item.Remercie, item.Details, item.Affectation) 1018 return ScanDon(row) 1019 } 1020 1021 // Update Don in the database and returns the new version. 1022 func (item Don) Update(tx DB) (out Don, err error) { 1023 row := tx.QueryRow(`UPDATE dons SET ( 1024 valeur,mode_paiement,date_reception,recu_emis,infos,remercie,details,affectation 1025 ) = ( 1026 $2,$3,$4,$5,$6,$7,$8,$9 1027 ) WHERE id = $1 RETURNING 1028 id,valeur,mode_paiement,date_reception,recu_emis,infos,remercie,details,affectation; 1029 `, item.Id, item.Valeur, item.ModePaiement, item.DateReception, item.RecuEmis, item.Infos, item.Remercie, item.Details, item.Affectation) 1030 return ScanDon(row) 1031 } 1032 1033 // Deletes the Don and returns the item 1034 func DeleteDonById(tx DB, id int64) (Don, error) { 1035 row := tx.QueryRow("DELETE FROM dons WHERE id = $1 RETURNING *;", id) 1036 return ScanDon(row) 1037 } 1038 1039 // Deletes the Don in the database and returns the ids. 1040 func DeleteDonsByIds(tx DB, ids ...int64) (Ids, error) { 1041 rows, err := tx.Query("DELETE FROM dons WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 1042 if err != nil { 1043 return nil, err 1044 } 1045 return ScanIds(rows) 1046 } 1047 1048 func scanOneDonDonateur(row scanner) (DonDonateur, error) { 1049 var s DonDonateur 1050 err := row.Scan( 1051 &s.IdDon, 1052 &s.IdPersonne, 1053 &s.IdOrganisme, 1054 ) 1055 return s, err 1056 } 1057 1058 func ScanDonDonateur(row *sql.Row) (DonDonateur, error) { 1059 return scanOneDonDonateur(row) 1060 } 1061 1062 func SelectAllDonDonateurs(tx DB) (DonDonateurs, error) { 1063 rows, err := tx.Query("SELECT * FROM don_donateurs") 1064 if err != nil { 1065 return nil, err 1066 } 1067 return ScanDonDonateurs(rows) 1068 } 1069 1070 type DonDonateurs []DonDonateur 1071 1072 func ScanDonDonateurs(rs *sql.Rows) (DonDonateurs, error) { 1073 var ( 1074 s DonDonateur 1075 err error 1076 ) 1077 defer func() { 1078 errClose := rs.Close() 1079 if err == nil { 1080 err = errClose 1081 } 1082 }() 1083 structs := make(DonDonateurs, 0, 16) 1084 for rs.Next() { 1085 s, err = scanOneDonDonateur(rs) 1086 if err != nil { 1087 return nil, err 1088 } 1089 structs = append(structs, s) 1090 } 1091 if err = rs.Err(); err != nil { 1092 return nil, err 1093 } 1094 return structs, nil 1095 } 1096 1097 // Insert the links DonDonateur in the database. 1098 func InsertManyDonDonateurs(tx *sql.Tx, items ...DonDonateur) error { 1099 if len(items) == 0 { 1100 return nil 1101 } 1102 1103 stmt, err := tx.Prepare(pq.CopyIn("don_donateurs", 1104 "id_don", "id_personne", "id_organisme", 1105 )) 1106 if err != nil { 1107 return err 1108 } 1109 1110 for _, item := range items { 1111 _, err = stmt.Exec(item.IdDon, item.IdPersonne, item.IdOrganisme) 1112 if err != nil { 1113 return err 1114 } 1115 } 1116 1117 if _, err = stmt.Exec(); err != nil { 1118 return err 1119 } 1120 1121 if err = stmt.Close(); err != nil { 1122 return err 1123 } 1124 return nil 1125 } 1126 1127 // Delete the link DonDonateur in the database. 1128 // Only the 'IdDon' 'IdPersonne' 'IdOrganisme' fields are used. 1129 func (item DonDonateur) Delete(tx DB) error { 1130 _, err := tx.Exec(`DELETE FROM don_donateurs WHERE 1131 id_don = $1 AND ( id_personne IS NULL OR id_personne = $2) AND ( id_organisme IS NULL OR id_organisme = $3);`, item.IdDon, item.IdPersonne, item.IdOrganisme) 1132 return err 1133 } 1134 1135 func scanOneEquipier(row scanner) (Equipier, error) { 1136 var s Equipier 1137 err := row.Scan( 1138 &s.Id, 1139 &s.IdCamp, 1140 &s.IdPersonne, 1141 &s.Roles, 1142 &s.Diplome, 1143 &s.Appro, 1144 &s.Presence, 1145 &s.InvitationEquipier, 1146 &s.Charte, 1147 ) 1148 return s, err 1149 } 1150 1151 func ScanEquipier(row *sql.Row) (Equipier, error) { 1152 return scanOneEquipier(row) 1153 } 1154 1155 func SelectAllEquipiers(tx DB) (Equipiers, error) { 1156 rows, err := tx.Query("SELECT * FROM equipiers") 1157 if err != nil { 1158 return nil, err 1159 } 1160 return ScanEquipiers(rows) 1161 } 1162 1163 // SelectEquipier returns the entry matching id. 1164 func SelectEquipier(tx DB, id int64) (Equipier, error) { 1165 row := tx.QueryRow("SELECT * FROM equipiers WHERE id = $1", id) 1166 return ScanEquipier(row) 1167 } 1168 1169 // SelectEquipiers returns the entry matching the given ids. 1170 func SelectEquipiers(tx DB, ids ...int64) (Equipiers, error) { 1171 rows, err := tx.Query("SELECT * FROM equipiers WHERE id = ANY($1)", pq.Int64Array(ids)) 1172 if err != nil { 1173 return nil, err 1174 } 1175 return ScanEquipiers(rows) 1176 } 1177 1178 type Equipiers map[int64]Equipier 1179 1180 func (m Equipiers) Ids() Ids { 1181 out := make(Ids, 0, len(m)) 1182 for i := range m { 1183 out = append(out, i) 1184 } 1185 return out 1186 } 1187 1188 func ScanEquipiers(rs *sql.Rows) (Equipiers, error) { 1189 var ( 1190 s Equipier 1191 err error 1192 ) 1193 defer func() { 1194 errClose := rs.Close() 1195 if err == nil { 1196 err = errClose 1197 } 1198 }() 1199 structs := make(Equipiers, 16) 1200 for rs.Next() { 1201 s, err = scanOneEquipier(rs) 1202 if err != nil { 1203 return nil, err 1204 } 1205 structs[s.Id] = s 1206 } 1207 if err = rs.Err(); err != nil { 1208 return nil, err 1209 } 1210 return structs, nil 1211 } 1212 1213 // Insert Equipier in the database and returns the item with id filled. 1214 func (item Equipier) Insert(tx DB) (out Equipier, err error) { 1215 row := tx.QueryRow(`INSERT INTO equipiers ( 1216 id_camp,id_personne,roles,diplome,appro,presence,invitation_equipier,charte 1217 ) VALUES ( 1218 $1,$2,$3,$4,$5,$6,$7,$8 1219 ) RETURNING 1220 id,id_camp,id_personne,roles,diplome,appro,presence,invitation_equipier,charte; 1221 `, item.IdCamp, item.IdPersonne, item.Roles, item.Diplome, item.Appro, item.Presence, item.InvitationEquipier, item.Charte) 1222 return ScanEquipier(row) 1223 } 1224 1225 // Update Equipier in the database and returns the new version. 1226 func (item Equipier) Update(tx DB) (out Equipier, err error) { 1227 row := tx.QueryRow(`UPDATE equipiers SET ( 1228 id_camp,id_personne,roles,diplome,appro,presence,invitation_equipier,charte 1229 ) = ( 1230 $2,$3,$4,$5,$6,$7,$8,$9 1231 ) WHERE id = $1 RETURNING 1232 id,id_camp,id_personne,roles,diplome,appro,presence,invitation_equipier,charte; 1233 `, item.Id, item.IdCamp, item.IdPersonne, item.Roles, item.Diplome, item.Appro, item.Presence, item.InvitationEquipier, item.Charte) 1234 return ScanEquipier(row) 1235 } 1236 1237 // Deletes the Equipier and returns the item 1238 func DeleteEquipierById(tx DB, id int64) (Equipier, error) { 1239 row := tx.QueryRow("DELETE FROM equipiers WHERE id = $1 RETURNING *;", id) 1240 return ScanEquipier(row) 1241 } 1242 1243 // Deletes the Equipier in the database and returns the ids. 1244 func DeleteEquipiersByIds(tx DB, ids ...int64) (Ids, error) { 1245 rows, err := tx.Query("DELETE FROM equipiers WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 1246 if err != nil { 1247 return nil, err 1248 } 1249 return ScanIds(rows) 1250 } 1251 1252 func scanOneEquipierContrainte(row scanner) (EquipierContrainte, error) { 1253 var s EquipierContrainte 1254 err := row.Scan( 1255 &s.IdEquipier, 1256 &s.IdContrainte, 1257 &s.Optionnel, 1258 ) 1259 return s, err 1260 } 1261 1262 func ScanEquipierContrainte(row *sql.Row) (EquipierContrainte, error) { 1263 return scanOneEquipierContrainte(row) 1264 } 1265 1266 func SelectAllEquipierContraintes(tx DB) (EquipierContraintes, error) { 1267 rows, err := tx.Query("SELECT * FROM equipier_contraintes") 1268 if err != nil { 1269 return nil, err 1270 } 1271 return ScanEquipierContraintes(rows) 1272 } 1273 1274 type EquipierContraintes []EquipierContrainte 1275 1276 func ScanEquipierContraintes(rs *sql.Rows) (EquipierContraintes, error) { 1277 var ( 1278 s EquipierContrainte 1279 err error 1280 ) 1281 defer func() { 1282 errClose := rs.Close() 1283 if err == nil { 1284 err = errClose 1285 } 1286 }() 1287 structs := make(EquipierContraintes, 0, 16) 1288 for rs.Next() { 1289 s, err = scanOneEquipierContrainte(rs) 1290 if err != nil { 1291 return nil, err 1292 } 1293 structs = append(structs, s) 1294 } 1295 if err = rs.Err(); err != nil { 1296 return nil, err 1297 } 1298 return structs, nil 1299 } 1300 1301 // Insert the links EquipierContrainte in the database. 1302 func InsertManyEquipierContraintes(tx *sql.Tx, items ...EquipierContrainte) error { 1303 if len(items) == 0 { 1304 return nil 1305 } 1306 1307 stmt, err := tx.Prepare(pq.CopyIn("equipier_contraintes", 1308 "id_equipier", "id_contrainte", "optionnel", 1309 )) 1310 if err != nil { 1311 return err 1312 } 1313 1314 for _, item := range items { 1315 _, err = stmt.Exec(item.IdEquipier, item.IdContrainte, item.Optionnel) 1316 if err != nil { 1317 return err 1318 } 1319 } 1320 1321 if _, err = stmt.Exec(); err != nil { 1322 return err 1323 } 1324 1325 if err = stmt.Close(); err != nil { 1326 return err 1327 } 1328 return nil 1329 } 1330 1331 // Delete the link EquipierContrainte in the database. 1332 // Only the 'IdEquipier' 'IdContrainte' fields are used. 1333 func (item EquipierContrainte) Delete(tx DB) error { 1334 _, err := tx.Exec(`DELETE FROM equipier_contraintes WHERE 1335 id_equipier = $1 AND id_contrainte = $2;`, item.IdEquipier, item.IdContrainte) 1336 return err 1337 } 1338 1339 func scanOneFacture(row scanner) (Facture, error) { 1340 var s Facture 1341 err := row.Scan( 1342 &s.Id, 1343 &s.IdPersonne, 1344 &s.DestinatairesOptionnels, 1345 &s.Key, 1346 &s.CopiesMails, 1347 &s.LastConnection, 1348 &s.IsConfirmed, 1349 &s.IsValidated, 1350 &s.PartageAdressesOK, 1351 ) 1352 return s, err 1353 } 1354 1355 func ScanFacture(row *sql.Row) (Facture, error) { 1356 return scanOneFacture(row) 1357 } 1358 1359 func SelectAllFactures(tx DB) (Factures, error) { 1360 rows, err := tx.Query("SELECT * FROM factures") 1361 if err != nil { 1362 return nil, err 1363 } 1364 return ScanFactures(rows) 1365 } 1366 1367 // SelectFacture returns the entry matching id. 1368 func SelectFacture(tx DB, id int64) (Facture, error) { 1369 row := tx.QueryRow("SELECT * FROM factures WHERE id = $1", id) 1370 return ScanFacture(row) 1371 } 1372 1373 // SelectFactures returns the entry matching the given ids. 1374 func SelectFactures(tx DB, ids ...int64) (Factures, error) { 1375 rows, err := tx.Query("SELECT * FROM factures WHERE id = ANY($1)", pq.Int64Array(ids)) 1376 if err != nil { 1377 return nil, err 1378 } 1379 return ScanFactures(rows) 1380 } 1381 1382 type Factures map[int64]Facture 1383 1384 func (m Factures) Ids() Ids { 1385 out := make(Ids, 0, len(m)) 1386 for i := range m { 1387 out = append(out, i) 1388 } 1389 return out 1390 } 1391 1392 func ScanFactures(rs *sql.Rows) (Factures, error) { 1393 var ( 1394 s Facture 1395 err error 1396 ) 1397 defer func() { 1398 errClose := rs.Close() 1399 if err == nil { 1400 err = errClose 1401 } 1402 }() 1403 structs := make(Factures, 16) 1404 for rs.Next() { 1405 s, err = scanOneFacture(rs) 1406 if err != nil { 1407 return nil, err 1408 } 1409 structs[s.Id] = s 1410 } 1411 if err = rs.Err(); err != nil { 1412 return nil, err 1413 } 1414 return structs, nil 1415 } 1416 1417 // Insert Facture in the database and returns the item with id filled. 1418 func (item Facture) Insert(tx DB) (out Facture, err error) { 1419 row := tx.QueryRow(`INSERT INTO factures ( 1420 id_personne,destinataires_optionnels,key,copies_mails,last_connection,is_confirmed,is_validated,partage_adresses_ok 1421 ) VALUES ( 1422 $1,$2,$3,$4,$5,$6,$7,$8 1423 ) RETURNING 1424 id,id_personne,destinataires_optionnels,key,copies_mails,last_connection,is_confirmed,is_validated,partage_adresses_ok; 1425 `, item.IdPersonne, item.DestinatairesOptionnels, item.Key, item.CopiesMails, item.LastConnection, item.IsConfirmed, item.IsValidated, item.PartageAdressesOK) 1426 return ScanFacture(row) 1427 } 1428 1429 // Update Facture in the database and returns the new version. 1430 func (item Facture) Update(tx DB) (out Facture, err error) { 1431 row := tx.QueryRow(`UPDATE factures SET ( 1432 id_personne,destinataires_optionnels,key,copies_mails,last_connection,is_confirmed,is_validated,partage_adresses_ok 1433 ) = ( 1434 $2,$3,$4,$5,$6,$7,$8,$9 1435 ) WHERE id = $1 RETURNING 1436 id,id_personne,destinataires_optionnels,key,copies_mails,last_connection,is_confirmed,is_validated,partage_adresses_ok; 1437 `, item.Id, item.IdPersonne, item.DestinatairesOptionnels, item.Key, item.CopiesMails, item.LastConnection, item.IsConfirmed, item.IsValidated, item.PartageAdressesOK) 1438 return ScanFacture(row) 1439 } 1440 1441 // Deletes the Facture and returns the item 1442 func DeleteFactureById(tx DB, id int64) (Facture, error) { 1443 row := tx.QueryRow("DELETE FROM factures WHERE id = $1 RETURNING *;", id) 1444 return ScanFacture(row) 1445 } 1446 1447 // Deletes the Facture in the database and returns the ids. 1448 func DeleteFacturesByIds(tx DB, ids ...int64) (Ids, error) { 1449 rows, err := tx.Query("DELETE FROM factures WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 1450 if err != nil { 1451 return nil, err 1452 } 1453 return ScanIds(rows) 1454 } 1455 1456 func scanOneGroupe(row scanner) (Groupe, error) { 1457 var s Groupe 1458 err := row.Scan( 1459 &s.Id, 1460 &s.IdCamp, 1461 &s.Nom, 1462 &s.Plage, 1463 &s.Couleur, 1464 &s.isSimple, 1465 ) 1466 return s, err 1467 } 1468 1469 func ScanGroupe(row *sql.Row) (Groupe, error) { 1470 return scanOneGroupe(row) 1471 } 1472 1473 func SelectAllGroupes(tx DB) (Groupes, error) { 1474 rows, err := tx.Query("SELECT * FROM groupes") 1475 if err != nil { 1476 return nil, err 1477 } 1478 return ScanGroupes(rows) 1479 } 1480 1481 // SelectGroupe returns the entry matching id. 1482 func SelectGroupe(tx DB, id int64) (Groupe, error) { 1483 row := tx.QueryRow("SELECT * FROM groupes WHERE id = $1", id) 1484 return ScanGroupe(row) 1485 } 1486 1487 // SelectGroupes returns the entry matching the given ids. 1488 func SelectGroupes(tx DB, ids ...int64) (Groupes, error) { 1489 rows, err := tx.Query("SELECT * FROM groupes WHERE id = ANY($1)", pq.Int64Array(ids)) 1490 if err != nil { 1491 return nil, err 1492 } 1493 return ScanGroupes(rows) 1494 } 1495 1496 type Groupes map[int64]Groupe 1497 1498 func (m Groupes) Ids() Ids { 1499 out := make(Ids, 0, len(m)) 1500 for i := range m { 1501 out = append(out, i) 1502 } 1503 return out 1504 } 1505 1506 func ScanGroupes(rs *sql.Rows) (Groupes, error) { 1507 var ( 1508 s Groupe 1509 err error 1510 ) 1511 defer func() { 1512 errClose := rs.Close() 1513 if err == nil { 1514 err = errClose 1515 } 1516 }() 1517 structs := make(Groupes, 16) 1518 for rs.Next() { 1519 s, err = scanOneGroupe(rs) 1520 if err != nil { 1521 return nil, err 1522 } 1523 structs[s.Id] = s 1524 } 1525 if err = rs.Err(); err != nil { 1526 return nil, err 1527 } 1528 return structs, nil 1529 } 1530 1531 // Insert Groupe in the database and returns the item with id filled. 1532 func (item Groupe) Insert(tx DB) (out Groupe, err error) { 1533 row := tx.QueryRow(`INSERT INTO groupes ( 1534 id_camp,nom,plage,couleur 1535 ) VALUES ( 1536 $1,$2,$3,$4 1537 ) RETURNING 1538 id,id_camp,nom,plage,couleur,isSimple; 1539 `, item.IdCamp, item.Nom, item.Plage, item.Couleur) 1540 return ScanGroupe(row) 1541 } 1542 1543 // Update Groupe in the database and returns the new version. 1544 func (item Groupe) Update(tx DB) (out Groupe, err error) { 1545 row := tx.QueryRow(`UPDATE groupes SET ( 1546 id_camp,nom,plage,couleur 1547 ) = ( 1548 $2,$3,$4,$5 1549 ) WHERE id = $1 RETURNING 1550 id,id_camp,nom,plage,couleur,isSimple; 1551 `, item.Id, item.IdCamp, item.Nom, item.Plage, item.Couleur) 1552 return ScanGroupe(row) 1553 } 1554 1555 // Deletes the Groupe and returns the item 1556 func DeleteGroupeById(tx DB, id int64) (Groupe, error) { 1557 row := tx.QueryRow("DELETE FROM groupes WHERE id = $1 RETURNING *;", id) 1558 return ScanGroupe(row) 1559 } 1560 1561 // Deletes the Groupe in the database and returns the ids. 1562 func DeleteGroupesByIds(tx DB, ids ...int64) (Ids, error) { 1563 rows, err := tx.Query("DELETE FROM groupes WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 1564 if err != nil { 1565 return nil, err 1566 } 1567 return ScanIds(rows) 1568 } 1569 1570 func scanOneGroupeContrainte(row scanner) (GroupeContrainte, error) { 1571 var s GroupeContrainte 1572 err := row.Scan( 1573 &s.IdGroupe, 1574 &s.IdContrainte, 1575 ) 1576 return s, err 1577 } 1578 1579 func ScanGroupeContrainte(row *sql.Row) (GroupeContrainte, error) { 1580 return scanOneGroupeContrainte(row) 1581 } 1582 1583 func SelectAllGroupeContraintes(tx DB) (GroupeContraintes, error) { 1584 rows, err := tx.Query("SELECT * FROM groupe_contraintes") 1585 if err != nil { 1586 return nil, err 1587 } 1588 return ScanGroupeContraintes(rows) 1589 } 1590 1591 type GroupeContraintes []GroupeContrainte 1592 1593 func ScanGroupeContraintes(rs *sql.Rows) (GroupeContraintes, error) { 1594 var ( 1595 s GroupeContrainte 1596 err error 1597 ) 1598 defer func() { 1599 errClose := rs.Close() 1600 if err == nil { 1601 err = errClose 1602 } 1603 }() 1604 structs := make(GroupeContraintes, 0, 16) 1605 for rs.Next() { 1606 s, err = scanOneGroupeContrainte(rs) 1607 if err != nil { 1608 return nil, err 1609 } 1610 structs = append(structs, s) 1611 } 1612 if err = rs.Err(); err != nil { 1613 return nil, err 1614 } 1615 return structs, nil 1616 } 1617 1618 // Insert the links GroupeContrainte in the database. 1619 func InsertManyGroupeContraintes(tx *sql.Tx, items ...GroupeContrainte) error { 1620 if len(items) == 0 { 1621 return nil 1622 } 1623 1624 stmt, err := tx.Prepare(pq.CopyIn("groupe_contraintes", 1625 "id_groupe", "id_contrainte", 1626 )) 1627 if err != nil { 1628 return err 1629 } 1630 1631 for _, item := range items { 1632 _, err = stmt.Exec(item.IdGroupe, item.IdContrainte) 1633 if err != nil { 1634 return err 1635 } 1636 } 1637 1638 if _, err = stmt.Exec(); err != nil { 1639 return err 1640 } 1641 1642 if err = stmt.Close(); err != nil { 1643 return err 1644 } 1645 return nil 1646 } 1647 1648 // Delete the link GroupeContrainte in the database. 1649 // Only the 'IdGroupe' 'IdContrainte' fields are used. 1650 func (item GroupeContrainte) Delete(tx DB) error { 1651 _, err := tx.Exec(`DELETE FROM groupe_contraintes WHERE 1652 id_groupe = $1 AND id_contrainte = $2;`, item.IdGroupe, item.IdContrainte) 1653 return err 1654 } 1655 1656 func scanOneGroupeEquipier(row scanner) (GroupeEquipier, error) { 1657 var s GroupeEquipier 1658 err := row.Scan( 1659 &s.IdGroupe, 1660 &s.IdEquipier, 1661 &s.IdCamp, 1662 ) 1663 return s, err 1664 } 1665 1666 func ScanGroupeEquipier(row *sql.Row) (GroupeEquipier, error) { 1667 return scanOneGroupeEquipier(row) 1668 } 1669 1670 func SelectAllGroupeEquipiers(tx DB) (GroupeEquipiers, error) { 1671 rows, err := tx.Query("SELECT * FROM groupe_equipiers") 1672 if err != nil { 1673 return nil, err 1674 } 1675 return ScanGroupeEquipiers(rows) 1676 } 1677 1678 type GroupeEquipiers []GroupeEquipier 1679 1680 func ScanGroupeEquipiers(rs *sql.Rows) (GroupeEquipiers, error) { 1681 var ( 1682 s GroupeEquipier 1683 err error 1684 ) 1685 defer func() { 1686 errClose := rs.Close() 1687 if err == nil { 1688 err = errClose 1689 } 1690 }() 1691 structs := make(GroupeEquipiers, 0, 16) 1692 for rs.Next() { 1693 s, err = scanOneGroupeEquipier(rs) 1694 if err != nil { 1695 return nil, err 1696 } 1697 structs = append(structs, s) 1698 } 1699 if err = rs.Err(); err != nil { 1700 return nil, err 1701 } 1702 return structs, nil 1703 } 1704 1705 // Insert the links GroupeEquipier in the database. 1706 func InsertManyGroupeEquipiers(tx *sql.Tx, items ...GroupeEquipier) error { 1707 if len(items) == 0 { 1708 return nil 1709 } 1710 1711 stmt, err := tx.Prepare(pq.CopyIn("groupe_equipiers", 1712 "id_groupe", "id_equipier", "id_camp", 1713 )) 1714 if err != nil { 1715 return err 1716 } 1717 1718 for _, item := range items { 1719 _, err = stmt.Exec(item.IdGroupe, item.IdEquipier, item.IdCamp) 1720 if err != nil { 1721 return err 1722 } 1723 } 1724 1725 if _, err = stmt.Exec(); err != nil { 1726 return err 1727 } 1728 1729 if err = stmt.Close(); err != nil { 1730 return err 1731 } 1732 return nil 1733 } 1734 1735 // Delete the link GroupeEquipier in the database. 1736 // Only the 'IdGroupe' 'IdEquipier' 'IdCamp' fields are used. 1737 func (item GroupeEquipier) Delete(tx DB) error { 1738 _, err := tx.Exec(`DELETE FROM groupe_equipiers WHERE 1739 id_groupe = $1 AND id_equipier = $2 AND id_camp = $3;`, item.IdGroupe, item.IdEquipier, item.IdCamp) 1740 return err 1741 } 1742 1743 func scanOneGroupeParticipant(row scanner) (GroupeParticipant, error) { 1744 var s GroupeParticipant 1745 err := row.Scan( 1746 &s.IdParticipant, 1747 &s.IdGroupe, 1748 &s.IdCamp, 1749 &s.Manuel, 1750 ) 1751 return s, err 1752 } 1753 1754 func ScanGroupeParticipant(row *sql.Row) (GroupeParticipant, error) { 1755 return scanOneGroupeParticipant(row) 1756 } 1757 1758 func SelectAllGroupeParticipants(tx DB) (GroupeParticipants, error) { 1759 rows, err := tx.Query("SELECT * FROM groupe_participants") 1760 if err != nil { 1761 return nil, err 1762 } 1763 return ScanGroupeParticipants(rows) 1764 } 1765 1766 type GroupeParticipants []GroupeParticipant 1767 1768 func ScanGroupeParticipants(rs *sql.Rows) (GroupeParticipants, error) { 1769 var ( 1770 s GroupeParticipant 1771 err error 1772 ) 1773 defer func() { 1774 errClose := rs.Close() 1775 if err == nil { 1776 err = errClose 1777 } 1778 }() 1779 structs := make(GroupeParticipants, 0, 16) 1780 for rs.Next() { 1781 s, err = scanOneGroupeParticipant(rs) 1782 if err != nil { 1783 return nil, err 1784 } 1785 structs = append(structs, s) 1786 } 1787 if err = rs.Err(); err != nil { 1788 return nil, err 1789 } 1790 return structs, nil 1791 } 1792 1793 // Insert the links GroupeParticipant in the database. 1794 func InsertManyGroupeParticipants(tx *sql.Tx, items ...GroupeParticipant) error { 1795 if len(items) == 0 { 1796 return nil 1797 } 1798 1799 stmt, err := tx.Prepare(pq.CopyIn("groupe_participants", 1800 "id_participant", "id_groupe", "id_camp", "manuel", 1801 )) 1802 if err != nil { 1803 return err 1804 } 1805 1806 for _, item := range items { 1807 _, err = stmt.Exec(item.IdParticipant, item.IdGroupe, item.IdCamp, item.Manuel) 1808 if err != nil { 1809 return err 1810 } 1811 } 1812 1813 if _, err = stmt.Exec(); err != nil { 1814 return err 1815 } 1816 1817 if err = stmt.Close(); err != nil { 1818 return err 1819 } 1820 return nil 1821 } 1822 1823 // Delete the link GroupeParticipant in the database. 1824 // Only the 'IdParticipant' 'IdGroupe' 'IdCamp' fields are used. 1825 func (item GroupeParticipant) Delete(tx DB) error { 1826 _, err := tx.Exec(`DELETE FROM groupe_participants WHERE 1827 id_participant = $1 AND id_groupe = $2 AND id_camp = $3;`, item.IdParticipant, item.IdGroupe, item.IdCamp) 1828 return err 1829 } 1830 1831 func scanOneImageuploaded(row scanner) (Imageuploaded, error) { 1832 var s Imageuploaded 1833 err := row.Scan( 1834 &s.IdCamp, 1835 &s.Filename, 1836 &s.Lien, 1837 &s.Content, 1838 ) 1839 return s, err 1840 } 1841 1842 func ScanImageuploaded(row *sql.Row) (Imageuploaded, error) { 1843 return scanOneImageuploaded(row) 1844 } 1845 1846 func SelectAllImageuploadeds(tx DB) (Imageuploadeds, error) { 1847 rows, err := tx.Query("SELECT * FROM imageuploadeds") 1848 if err != nil { 1849 return nil, err 1850 } 1851 return ScanImageuploadeds(rows) 1852 } 1853 1854 type Imageuploadeds []Imageuploaded 1855 1856 func ScanImageuploadeds(rs *sql.Rows) (Imageuploadeds, error) { 1857 var ( 1858 s Imageuploaded 1859 err error 1860 ) 1861 defer func() { 1862 errClose := rs.Close() 1863 if err == nil { 1864 err = errClose 1865 } 1866 }() 1867 structs := make(Imageuploadeds, 0, 16) 1868 for rs.Next() { 1869 s, err = scanOneImageuploaded(rs) 1870 if err != nil { 1871 return nil, err 1872 } 1873 structs = append(structs, s) 1874 } 1875 if err = rs.Err(); err != nil { 1876 return nil, err 1877 } 1878 return structs, nil 1879 } 1880 1881 // Insert the links Imageuploaded in the database. 1882 func InsertManyImageuploadeds(tx *sql.Tx, items ...Imageuploaded) error { 1883 if len(items) == 0 { 1884 return nil 1885 } 1886 1887 stmt, err := tx.Prepare(pq.CopyIn("imageuploadeds", 1888 "id_camp", "filename", "lien", "content", 1889 )) 1890 if err != nil { 1891 return err 1892 } 1893 1894 for _, item := range items { 1895 _, err = stmt.Exec(item.IdCamp, item.Filename, item.Lien, item.Content) 1896 if err != nil { 1897 return err 1898 } 1899 } 1900 1901 if _, err = stmt.Exec(); err != nil { 1902 return err 1903 } 1904 1905 if err = stmt.Close(); err != nil { 1906 return err 1907 } 1908 return nil 1909 } 1910 1911 // Delete the link Imageuploaded in the database. 1912 // Only the 'IdCamp' fields are used. 1913 func (item Imageuploaded) Delete(tx DB) error { 1914 _, err := tx.Exec(`DELETE FROM imageuploadeds WHERE 1915 id_camp = $1;`, item.IdCamp) 1916 return err 1917 } 1918 1919 func scanOneInscription(row scanner) (Inscription, error) { 1920 var s Inscription 1921 err := row.Scan( 1922 &s.Id, 1923 &s.Info, 1924 &s.DateHeure, 1925 &s.CopiesMails, 1926 &s.Responsable, 1927 &s.Participants, 1928 &s.PartageAdressesOK, 1929 ) 1930 return s, err 1931 } 1932 1933 func ScanInscription(row *sql.Row) (Inscription, error) { 1934 return scanOneInscription(row) 1935 } 1936 1937 func SelectAllInscriptions(tx DB) (Inscriptions, error) { 1938 rows, err := tx.Query("SELECT * FROM inscriptions") 1939 if err != nil { 1940 return nil, err 1941 } 1942 return ScanInscriptions(rows) 1943 } 1944 1945 // SelectInscription returns the entry matching id. 1946 func SelectInscription(tx DB, id int64) (Inscription, error) { 1947 row := tx.QueryRow("SELECT * FROM inscriptions WHERE id = $1", id) 1948 return ScanInscription(row) 1949 } 1950 1951 // SelectInscriptions returns the entry matching the given ids. 1952 func SelectInscriptions(tx DB, ids ...int64) (Inscriptions, error) { 1953 rows, err := tx.Query("SELECT * FROM inscriptions WHERE id = ANY($1)", pq.Int64Array(ids)) 1954 if err != nil { 1955 return nil, err 1956 } 1957 return ScanInscriptions(rows) 1958 } 1959 1960 type Inscriptions map[int64]Inscription 1961 1962 func (m Inscriptions) Ids() Ids { 1963 out := make(Ids, 0, len(m)) 1964 for i := range m { 1965 out = append(out, i) 1966 } 1967 return out 1968 } 1969 1970 func ScanInscriptions(rs *sql.Rows) (Inscriptions, error) { 1971 var ( 1972 s Inscription 1973 err error 1974 ) 1975 defer func() { 1976 errClose := rs.Close() 1977 if err == nil { 1978 err = errClose 1979 } 1980 }() 1981 structs := make(Inscriptions, 16) 1982 for rs.Next() { 1983 s, err = scanOneInscription(rs) 1984 if err != nil { 1985 return nil, err 1986 } 1987 structs[s.Id] = s 1988 } 1989 if err = rs.Err(); err != nil { 1990 return nil, err 1991 } 1992 return structs, nil 1993 } 1994 1995 // Insert Inscription in the database and returns the item with id filled. 1996 func (item Inscription) Insert(tx DB) (out Inscription, err error) { 1997 row := tx.QueryRow(`INSERT INTO inscriptions ( 1998 info,date_heure,copies_mails,responsable,participants,partage_adresses_ok 1999 ) VALUES ( 2000 $1,$2,$3,$4,$5,$6 2001 ) RETURNING 2002 id,info,date_heure,copies_mails,responsable,participants,partage_adresses_ok; 2003 `, item.Info, item.DateHeure, item.CopiesMails, item.Responsable, item.Participants, item.PartageAdressesOK) 2004 return ScanInscription(row) 2005 } 2006 2007 // Update Inscription in the database and returns the new version. 2008 func (item Inscription) Update(tx DB) (out Inscription, err error) { 2009 row := tx.QueryRow(`UPDATE inscriptions SET ( 2010 info,date_heure,copies_mails,responsable,participants,partage_adresses_ok 2011 ) = ( 2012 $2,$3,$4,$5,$6,$7 2013 ) WHERE id = $1 RETURNING 2014 id,info,date_heure,copies_mails,responsable,participants,partage_adresses_ok; 2015 `, item.Id, item.Info, item.DateHeure, item.CopiesMails, item.Responsable, item.Participants, item.PartageAdressesOK) 2016 return ScanInscription(row) 2017 } 2018 2019 // Deletes the Inscription and returns the item 2020 func DeleteInscriptionById(tx DB, id int64) (Inscription, error) { 2021 row := tx.QueryRow("DELETE FROM inscriptions WHERE id = $1 RETURNING *;", id) 2022 return ScanInscription(row) 2023 } 2024 2025 // Deletes the Inscription in the database and returns the ids. 2026 func DeleteInscriptionsByIds(tx DB, ids ...int64) (Ids, error) { 2027 rows, err := tx.Query("DELETE FROM inscriptions WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 2028 if err != nil { 2029 return nil, err 2030 } 2031 return ScanIds(rows) 2032 } 2033 2034 func scanOneLettredirecteur(row scanner) (Lettredirecteur, error) { 2035 var s Lettredirecteur 2036 err := row.Scan( 2037 &s.IdCamp, 2038 &s.Html, 2039 &s.UseCoordCentre, 2040 &s.ShowAdressePostale, 2041 &s.ColorCoord, 2042 ) 2043 return s, err 2044 } 2045 2046 func ScanLettredirecteur(row *sql.Row) (Lettredirecteur, error) { 2047 return scanOneLettredirecteur(row) 2048 } 2049 2050 func SelectAllLettredirecteurs(tx DB) (Lettredirecteurs, error) { 2051 rows, err := tx.Query("SELECT * FROM lettredirecteurs") 2052 if err != nil { 2053 return nil, err 2054 } 2055 return ScanLettredirecteurs(rows) 2056 } 2057 2058 type Lettredirecteurs []Lettredirecteur 2059 2060 func ScanLettredirecteurs(rs *sql.Rows) (Lettredirecteurs, error) { 2061 var ( 2062 s Lettredirecteur 2063 err error 2064 ) 2065 defer func() { 2066 errClose := rs.Close() 2067 if err == nil { 2068 err = errClose 2069 } 2070 }() 2071 structs := make(Lettredirecteurs, 0, 16) 2072 for rs.Next() { 2073 s, err = scanOneLettredirecteur(rs) 2074 if err != nil { 2075 return nil, err 2076 } 2077 structs = append(structs, s) 2078 } 2079 if err = rs.Err(); err != nil { 2080 return nil, err 2081 } 2082 return structs, nil 2083 } 2084 2085 // Insert the links Lettredirecteur in the database. 2086 func InsertManyLettredirecteurs(tx *sql.Tx, items ...Lettredirecteur) error { 2087 if len(items) == 0 { 2088 return nil 2089 } 2090 2091 stmt, err := tx.Prepare(pq.CopyIn("lettredirecteurs", 2092 "id_camp", "html", "use_coord_centre", "show_adresse_postale", "color_coord", 2093 )) 2094 if err != nil { 2095 return err 2096 } 2097 2098 for _, item := range items { 2099 _, err = stmt.Exec(item.IdCamp, item.Html, item.UseCoordCentre, item.ShowAdressePostale, item.ColorCoord) 2100 if err != nil { 2101 return err 2102 } 2103 } 2104 2105 if _, err = stmt.Exec(); err != nil { 2106 return err 2107 } 2108 2109 if err = stmt.Close(); err != nil { 2110 return err 2111 } 2112 return nil 2113 } 2114 2115 // Delete the link Lettredirecteur in the database. 2116 // Only the 'IdCamp' fields are used. 2117 func (item Lettredirecteur) Delete(tx DB) error { 2118 _, err := tx.Exec(`DELETE FROM lettredirecteurs WHERE 2119 id_camp = $1;`, item.IdCamp) 2120 return err 2121 } 2122 2123 func scanOneMessage(row scanner) (Message, error) { 2124 var s Message 2125 err := row.Scan( 2126 &s.Id, 2127 &s.IdFacture, 2128 &s.Kind, 2129 &s.Created, 2130 &s.Modified, 2131 &s.Vu, 2132 ) 2133 return s, err 2134 } 2135 2136 func ScanMessage(row *sql.Row) (Message, error) { 2137 return scanOneMessage(row) 2138 } 2139 2140 func SelectAllMessages(tx DB) (Messages, error) { 2141 rows, err := tx.Query("SELECT * FROM messages") 2142 if err != nil { 2143 return nil, err 2144 } 2145 return ScanMessages(rows) 2146 } 2147 2148 // SelectMessage returns the entry matching id. 2149 func SelectMessage(tx DB, id int64) (Message, error) { 2150 row := tx.QueryRow("SELECT * FROM messages WHERE id = $1", id) 2151 return ScanMessage(row) 2152 } 2153 2154 // SelectMessages returns the entry matching the given ids. 2155 func SelectMessages(tx DB, ids ...int64) (Messages, error) { 2156 rows, err := tx.Query("SELECT * FROM messages WHERE id = ANY($1)", pq.Int64Array(ids)) 2157 if err != nil { 2158 return nil, err 2159 } 2160 return ScanMessages(rows) 2161 } 2162 2163 type Messages map[int64]Message 2164 2165 func (m Messages) Ids() Ids { 2166 out := make(Ids, 0, len(m)) 2167 for i := range m { 2168 out = append(out, i) 2169 } 2170 return out 2171 } 2172 2173 func ScanMessages(rs *sql.Rows) (Messages, error) { 2174 var ( 2175 s Message 2176 err error 2177 ) 2178 defer func() { 2179 errClose := rs.Close() 2180 if err == nil { 2181 err = errClose 2182 } 2183 }() 2184 structs := make(Messages, 16) 2185 for rs.Next() { 2186 s, err = scanOneMessage(rs) 2187 if err != nil { 2188 return nil, err 2189 } 2190 structs[s.Id] = s 2191 } 2192 if err = rs.Err(); err != nil { 2193 return nil, err 2194 } 2195 return structs, nil 2196 } 2197 2198 // Insert Message in the database and returns the item with id filled. 2199 func (item Message) Insert(tx DB) (out Message, err error) { 2200 row := tx.QueryRow(`INSERT INTO messages ( 2201 id_facture,kind,created,modified,vu 2202 ) VALUES ( 2203 $1,$2,$3,$4,$5 2204 ) RETURNING 2205 id,id_facture,kind,created,modified,vu; 2206 `, item.IdFacture, item.Kind, item.Created, item.Modified, item.Vu) 2207 return ScanMessage(row) 2208 } 2209 2210 // Update Message in the database and returns the new version. 2211 func (item Message) Update(tx DB) (out Message, err error) { 2212 row := tx.QueryRow(`UPDATE messages SET ( 2213 id_facture,kind,created,modified,vu 2214 ) = ( 2215 $2,$3,$4,$5,$6 2216 ) WHERE id = $1 RETURNING 2217 id,id_facture,kind,created,modified,vu; 2218 `, item.Id, item.IdFacture, item.Kind, item.Created, item.Modified, item.Vu) 2219 return ScanMessage(row) 2220 } 2221 2222 // Deletes the Message and returns the item 2223 func DeleteMessageById(tx DB, id int64) (Message, error) { 2224 row := tx.QueryRow("DELETE FROM messages WHERE id = $1 RETURNING *;", id) 2225 return ScanMessage(row) 2226 } 2227 2228 // Deletes the Message in the database and returns the ids. 2229 func DeleteMessagesByIds(tx DB, ids ...int64) (Ids, error) { 2230 rows, err := tx.Query("DELETE FROM messages WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 2231 if err != nil { 2232 return nil, err 2233 } 2234 return ScanIds(rows) 2235 } 2236 2237 func scanOneMessageAttestation(row scanner) (MessageAttestation, error) { 2238 var s MessageAttestation 2239 err := row.Scan( 2240 &s.IdMessage, 2241 &s.Distribution, 2242 &s.GuardKind, 2243 ) 2244 return s, err 2245 } 2246 2247 func ScanMessageAttestation(row *sql.Row) (MessageAttestation, error) { 2248 return scanOneMessageAttestation(row) 2249 } 2250 2251 func SelectAllMessageAttestations(tx DB) (MessageAttestations, error) { 2252 rows, err := tx.Query("SELECT * FROM message_attestations") 2253 if err != nil { 2254 return nil, err 2255 } 2256 return ScanMessageAttestations(rows) 2257 } 2258 2259 type MessageAttestations []MessageAttestation 2260 2261 func ScanMessageAttestations(rs *sql.Rows) (MessageAttestations, error) { 2262 var ( 2263 s MessageAttestation 2264 err error 2265 ) 2266 defer func() { 2267 errClose := rs.Close() 2268 if err == nil { 2269 err = errClose 2270 } 2271 }() 2272 structs := make(MessageAttestations, 0, 16) 2273 for rs.Next() { 2274 s, err = scanOneMessageAttestation(rs) 2275 if err != nil { 2276 return nil, err 2277 } 2278 structs = append(structs, s) 2279 } 2280 if err = rs.Err(); err != nil { 2281 return nil, err 2282 } 2283 return structs, nil 2284 } 2285 2286 // Insert the links MessageAttestation in the database. 2287 func InsertManyMessageAttestations(tx *sql.Tx, items ...MessageAttestation) error { 2288 if len(items) == 0 { 2289 return nil 2290 } 2291 2292 stmt, err := tx.Prepare(pq.CopyIn("message_attestations", 2293 "id_message", "distribution", "guard_kind", 2294 )) 2295 if err != nil { 2296 return err 2297 } 2298 2299 for _, item := range items { 2300 _, err = stmt.Exec(item.IdMessage, item.Distribution, item.GuardKind) 2301 if err != nil { 2302 return err 2303 } 2304 } 2305 2306 if _, err = stmt.Exec(); err != nil { 2307 return err 2308 } 2309 2310 if err = stmt.Close(); err != nil { 2311 return err 2312 } 2313 return nil 2314 } 2315 2316 // Delete the link MessageAttestation in the database. 2317 // Only the 'IdMessage' fields are used. 2318 func (item MessageAttestation) Delete(tx DB) error { 2319 _, err := tx.Exec(`DELETE FROM message_attestations WHERE 2320 id_message = $1;`, item.IdMessage) 2321 return err 2322 } 2323 2324 func scanOneMessageDocument(row scanner) (MessageDocument, error) { 2325 var s MessageDocument 2326 err := row.Scan( 2327 &s.IdMessage, 2328 &s.IdCamp, 2329 &s.guardKind, 2330 ) 2331 return s, err 2332 } 2333 2334 func ScanMessageDocument(row *sql.Row) (MessageDocument, error) { 2335 return scanOneMessageDocument(row) 2336 } 2337 2338 func SelectAllMessageDocuments(tx DB) (MessageDocuments, error) { 2339 rows, err := tx.Query("SELECT * FROM message_documents") 2340 if err != nil { 2341 return nil, err 2342 } 2343 return ScanMessageDocuments(rows) 2344 } 2345 2346 type MessageDocuments []MessageDocument 2347 2348 func ScanMessageDocuments(rs *sql.Rows) (MessageDocuments, error) { 2349 var ( 2350 s MessageDocument 2351 err error 2352 ) 2353 defer func() { 2354 errClose := rs.Close() 2355 if err == nil { 2356 err = errClose 2357 } 2358 }() 2359 structs := make(MessageDocuments, 0, 16) 2360 for rs.Next() { 2361 s, err = scanOneMessageDocument(rs) 2362 if err != nil { 2363 return nil, err 2364 } 2365 structs = append(structs, s) 2366 } 2367 if err = rs.Err(); err != nil { 2368 return nil, err 2369 } 2370 return structs, nil 2371 } 2372 2373 // Insert the links MessageDocument in the database. 2374 func InsertManyMessageDocuments(tx *sql.Tx, items ...MessageDocument) error { 2375 if len(items) == 0 { 2376 return nil 2377 } 2378 2379 stmt, err := tx.Prepare(pq.CopyIn("message_documents", 2380 "id_message", "id_camp", 2381 )) 2382 if err != nil { 2383 return err 2384 } 2385 2386 for _, item := range items { 2387 _, err = stmt.Exec(item.IdMessage, item.IdCamp) 2388 if err != nil { 2389 return err 2390 } 2391 } 2392 2393 if _, err = stmt.Exec(); err != nil { 2394 return err 2395 } 2396 2397 if err = stmt.Close(); err != nil { 2398 return err 2399 } 2400 return nil 2401 } 2402 2403 // Delete the link MessageDocument in the database. 2404 // Only the 'IdMessage' 'IdCamp' fields are used. 2405 func (item MessageDocument) Delete(tx DB) error { 2406 _, err := tx.Exec(`DELETE FROM message_documents WHERE 2407 id_message = $1 AND id_camp = $2;`, item.IdMessage, item.IdCamp) 2408 return err 2409 } 2410 2411 func scanOneMessageMessage(row scanner) (MessageMessage, error) { 2412 var s MessageMessage 2413 err := row.Scan( 2414 &s.IdMessage, 2415 &s.Contenu, 2416 &s.GuardKind, 2417 ) 2418 return s, err 2419 } 2420 2421 func ScanMessageMessage(row *sql.Row) (MessageMessage, error) { 2422 return scanOneMessageMessage(row) 2423 } 2424 2425 func SelectAllMessageMessages(tx DB) (MessageMessages, error) { 2426 rows, err := tx.Query("SELECT * FROM message_messages") 2427 if err != nil { 2428 return nil, err 2429 } 2430 return ScanMessageMessages(rows) 2431 } 2432 2433 type MessageMessages []MessageMessage 2434 2435 func ScanMessageMessages(rs *sql.Rows) (MessageMessages, error) { 2436 var ( 2437 s MessageMessage 2438 err error 2439 ) 2440 defer func() { 2441 errClose := rs.Close() 2442 if err == nil { 2443 err = errClose 2444 } 2445 }() 2446 structs := make(MessageMessages, 0, 16) 2447 for rs.Next() { 2448 s, err = scanOneMessageMessage(rs) 2449 if err != nil { 2450 return nil, err 2451 } 2452 structs = append(structs, s) 2453 } 2454 if err = rs.Err(); err != nil { 2455 return nil, err 2456 } 2457 return structs, nil 2458 } 2459 2460 // Insert the links MessageMessage in the database. 2461 func InsertManyMessageMessages(tx *sql.Tx, items ...MessageMessage) error { 2462 if len(items) == 0 { 2463 return nil 2464 } 2465 2466 stmt, err := tx.Prepare(pq.CopyIn("message_messages", 2467 "id_message", "contenu", "guard_kind", 2468 )) 2469 if err != nil { 2470 return err 2471 } 2472 2473 for _, item := range items { 2474 _, err = stmt.Exec(item.IdMessage, item.Contenu, item.GuardKind) 2475 if err != nil { 2476 return err 2477 } 2478 } 2479 2480 if _, err = stmt.Exec(); err != nil { 2481 return err 2482 } 2483 2484 if err = stmt.Close(); err != nil { 2485 return err 2486 } 2487 return nil 2488 } 2489 2490 // Delete the link MessageMessage in the database. 2491 // Only the 'IdMessage' fields are used. 2492 func (item MessageMessage) Delete(tx DB) error { 2493 _, err := tx.Exec(`DELETE FROM message_messages WHERE 2494 id_message = $1;`, item.IdMessage) 2495 return err 2496 } 2497 2498 func scanOneMessagePlacelibere(row scanner) (MessagePlacelibere, error) { 2499 var s MessagePlacelibere 2500 err := row.Scan( 2501 &s.IdMessage, 2502 &s.IdParticipant, 2503 &s.guardKind, 2504 ) 2505 return s, err 2506 } 2507 2508 func ScanMessagePlacelibere(row *sql.Row) (MessagePlacelibere, error) { 2509 return scanOneMessagePlacelibere(row) 2510 } 2511 2512 func SelectAllMessagePlaceliberes(tx DB) (MessagePlaceliberes, error) { 2513 rows, err := tx.Query("SELECT * FROM message_placeliberes") 2514 if err != nil { 2515 return nil, err 2516 } 2517 return ScanMessagePlaceliberes(rows) 2518 } 2519 2520 type MessagePlaceliberes []MessagePlacelibere 2521 2522 func ScanMessagePlaceliberes(rs *sql.Rows) (MessagePlaceliberes, error) { 2523 var ( 2524 s MessagePlacelibere 2525 err error 2526 ) 2527 defer func() { 2528 errClose := rs.Close() 2529 if err == nil { 2530 err = errClose 2531 } 2532 }() 2533 structs := make(MessagePlaceliberes, 0, 16) 2534 for rs.Next() { 2535 s, err = scanOneMessagePlacelibere(rs) 2536 if err != nil { 2537 return nil, err 2538 } 2539 structs = append(structs, s) 2540 } 2541 if err = rs.Err(); err != nil { 2542 return nil, err 2543 } 2544 return structs, nil 2545 } 2546 2547 // Insert the links MessagePlacelibere in the database. 2548 func InsertManyMessagePlaceliberes(tx *sql.Tx, items ...MessagePlacelibere) error { 2549 if len(items) == 0 { 2550 return nil 2551 } 2552 2553 stmt, err := tx.Prepare(pq.CopyIn("message_placeliberes", 2554 "id_message", "id_participant", 2555 )) 2556 if err != nil { 2557 return err 2558 } 2559 2560 for _, item := range items { 2561 _, err = stmt.Exec(item.IdMessage, item.IdParticipant) 2562 if err != nil { 2563 return err 2564 } 2565 } 2566 2567 if _, err = stmt.Exec(); err != nil { 2568 return err 2569 } 2570 2571 if err = stmt.Close(); err != nil { 2572 return err 2573 } 2574 return nil 2575 } 2576 2577 // Delete the link MessagePlacelibere in the database. 2578 // Only the 'IdMessage' 'IdParticipant' fields are used. 2579 func (item MessagePlacelibere) Delete(tx DB) error { 2580 _, err := tx.Exec(`DELETE FROM message_placeliberes WHERE 2581 id_message = $1 AND id_participant = $2;`, item.IdMessage, item.IdParticipant) 2582 return err 2583 } 2584 2585 func scanOneMessageSondage(row scanner) (MessageSondage, error) { 2586 var s MessageSondage 2587 err := row.Scan( 2588 &s.IdMessage, 2589 &s.IdCamp, 2590 &s.guardKind, 2591 &s.isSimple, 2592 ) 2593 return s, err 2594 } 2595 2596 func ScanMessageSondage(row *sql.Row) (MessageSondage, error) { 2597 return scanOneMessageSondage(row) 2598 } 2599 2600 func SelectAllMessageSondages(tx DB) (MessageSondages, error) { 2601 rows, err := tx.Query("SELECT * FROM message_sondages") 2602 if err != nil { 2603 return nil, err 2604 } 2605 return ScanMessageSondages(rows) 2606 } 2607 2608 type MessageSondages []MessageSondage 2609 2610 func ScanMessageSondages(rs *sql.Rows) (MessageSondages, error) { 2611 var ( 2612 s MessageSondage 2613 err error 2614 ) 2615 defer func() { 2616 errClose := rs.Close() 2617 if err == nil { 2618 err = errClose 2619 } 2620 }() 2621 structs := make(MessageSondages, 0, 16) 2622 for rs.Next() { 2623 s, err = scanOneMessageSondage(rs) 2624 if err != nil { 2625 return nil, err 2626 } 2627 structs = append(structs, s) 2628 } 2629 if err = rs.Err(); err != nil { 2630 return nil, err 2631 } 2632 return structs, nil 2633 } 2634 2635 // Insert the links MessageSondage in the database. 2636 func InsertManyMessageSondages(tx *sql.Tx, items ...MessageSondage) error { 2637 if len(items) == 0 { 2638 return nil 2639 } 2640 2641 stmt, err := tx.Prepare(pq.CopyIn("message_sondages", 2642 "id_message", "id_camp", 2643 )) 2644 if err != nil { 2645 return err 2646 } 2647 2648 for _, item := range items { 2649 _, err = stmt.Exec(item.IdMessage, item.IdCamp) 2650 if err != nil { 2651 return err 2652 } 2653 } 2654 2655 if _, err = stmt.Exec(); err != nil { 2656 return err 2657 } 2658 2659 if err = stmt.Close(); err != nil { 2660 return err 2661 } 2662 return nil 2663 } 2664 2665 // Delete the link MessageSondage in the database. 2666 // Only the 'IdMessage' 'IdCamp' fields are used. 2667 func (item MessageSondage) Delete(tx DB) error { 2668 _, err := tx.Exec(`DELETE FROM message_sondages WHERE 2669 id_message = $1 AND id_camp = $2;`, item.IdMessage, item.IdCamp) 2670 return err 2671 } 2672 2673 func scanOneOrganisme(row scanner) (Organisme, error) { 2674 var s Organisme 2675 err := row.Scan( 2676 &s.Id, 2677 &s.Nom, 2678 &s.ContactPropre, 2679 &s.Contact, 2680 &s.IdContact, 2681 &s.IdContactDon, 2682 &s.Exemplaires, 2683 ) 2684 return s, err 2685 } 2686 2687 func ScanOrganisme(row *sql.Row) (Organisme, error) { 2688 return scanOneOrganisme(row) 2689 } 2690 2691 func SelectAllOrganismes(tx DB) (Organismes, error) { 2692 rows, err := tx.Query("SELECT * FROM organismes") 2693 if err != nil { 2694 return nil, err 2695 } 2696 return ScanOrganismes(rows) 2697 } 2698 2699 // SelectOrganisme returns the entry matching id. 2700 func SelectOrganisme(tx DB, id int64) (Organisme, error) { 2701 row := tx.QueryRow("SELECT * FROM organismes WHERE id = $1", id) 2702 return ScanOrganisme(row) 2703 } 2704 2705 // SelectOrganismes returns the entry matching the given ids. 2706 func SelectOrganismes(tx DB, ids ...int64) (Organismes, error) { 2707 rows, err := tx.Query("SELECT * FROM organismes WHERE id = ANY($1)", pq.Int64Array(ids)) 2708 if err != nil { 2709 return nil, err 2710 } 2711 return ScanOrganismes(rows) 2712 } 2713 2714 type Organismes map[int64]Organisme 2715 2716 func (m Organismes) Ids() Ids { 2717 out := make(Ids, 0, len(m)) 2718 for i := range m { 2719 out = append(out, i) 2720 } 2721 return out 2722 } 2723 2724 func ScanOrganismes(rs *sql.Rows) (Organismes, error) { 2725 var ( 2726 s Organisme 2727 err error 2728 ) 2729 defer func() { 2730 errClose := rs.Close() 2731 if err == nil { 2732 err = errClose 2733 } 2734 }() 2735 structs := make(Organismes, 16) 2736 for rs.Next() { 2737 s, err = scanOneOrganisme(rs) 2738 if err != nil { 2739 return nil, err 2740 } 2741 structs[s.Id] = s 2742 } 2743 if err = rs.Err(); err != nil { 2744 return nil, err 2745 } 2746 return structs, nil 2747 } 2748 2749 // Insert Organisme in the database and returns the item with id filled. 2750 func (item Organisme) Insert(tx DB) (out Organisme, err error) { 2751 row := tx.QueryRow(`INSERT INTO organismes ( 2752 nom,contact_propre,contact,id_contact,id_contact_don,exemplaires 2753 ) VALUES ( 2754 $1,$2,$3,$4,$5,$6 2755 ) RETURNING 2756 id,nom,contact_propre,contact,id_contact,id_contact_don,exemplaires; 2757 `, item.Nom, item.ContactPropre, item.Contact, item.IdContact, item.IdContactDon, item.Exemplaires) 2758 return ScanOrganisme(row) 2759 } 2760 2761 // Update Organisme in the database and returns the new version. 2762 func (item Organisme) Update(tx DB) (out Organisme, err error) { 2763 row := tx.QueryRow(`UPDATE organismes SET ( 2764 nom,contact_propre,contact,id_contact,id_contact_don,exemplaires 2765 ) = ( 2766 $2,$3,$4,$5,$6,$7 2767 ) WHERE id = $1 RETURNING 2768 id,nom,contact_propre,contact,id_contact,id_contact_don,exemplaires; 2769 `, item.Id, item.Nom, item.ContactPropre, item.Contact, item.IdContact, item.IdContactDon, item.Exemplaires) 2770 return ScanOrganisme(row) 2771 } 2772 2773 // Deletes the Organisme and returns the item 2774 func DeleteOrganismeById(tx DB, id int64) (Organisme, error) { 2775 row := tx.QueryRow("DELETE FROM organismes WHERE id = $1 RETURNING *;", id) 2776 return ScanOrganisme(row) 2777 } 2778 2779 // Deletes the Organisme in the database and returns the ids. 2780 func DeleteOrganismesByIds(tx DB, ids ...int64) (Ids, error) { 2781 rows, err := tx.Query("DELETE FROM organismes WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 2782 if err != nil { 2783 return nil, err 2784 } 2785 return ScanIds(rows) 2786 } 2787 2788 func scanOnePaiement(row scanner) (Paiement, error) { 2789 var s Paiement 2790 err := row.Scan( 2791 &s.Id, 2792 &s.IdFacture, 2793 &s.IsAcompte, 2794 &s.IsRemboursement, 2795 &s.InBordereau, 2796 &s.LabelPayeur, 2797 &s.NomBanque, 2798 &s.ModePaiement, 2799 &s.Numero, 2800 &s.Valeur, 2801 &s.IsInvalide, 2802 &s.DateReglement, 2803 &s.Details, 2804 ) 2805 return s, err 2806 } 2807 2808 func ScanPaiement(row *sql.Row) (Paiement, error) { 2809 return scanOnePaiement(row) 2810 } 2811 2812 func SelectAllPaiements(tx DB) (Paiements, error) { 2813 rows, err := tx.Query("SELECT * FROM paiements") 2814 if err != nil { 2815 return nil, err 2816 } 2817 return ScanPaiements(rows) 2818 } 2819 2820 // SelectPaiement returns the entry matching id. 2821 func SelectPaiement(tx DB, id int64) (Paiement, error) { 2822 row := tx.QueryRow("SELECT * FROM paiements WHERE id = $1", id) 2823 return ScanPaiement(row) 2824 } 2825 2826 // SelectPaiements returns the entry matching the given ids. 2827 func SelectPaiements(tx DB, ids ...int64) (Paiements, error) { 2828 rows, err := tx.Query("SELECT * FROM paiements WHERE id = ANY($1)", pq.Int64Array(ids)) 2829 if err != nil { 2830 return nil, err 2831 } 2832 return ScanPaiements(rows) 2833 } 2834 2835 type Paiements map[int64]Paiement 2836 2837 func (m Paiements) Ids() Ids { 2838 out := make(Ids, 0, len(m)) 2839 for i := range m { 2840 out = append(out, i) 2841 } 2842 return out 2843 } 2844 2845 func ScanPaiements(rs *sql.Rows) (Paiements, error) { 2846 var ( 2847 s Paiement 2848 err error 2849 ) 2850 defer func() { 2851 errClose := rs.Close() 2852 if err == nil { 2853 err = errClose 2854 } 2855 }() 2856 structs := make(Paiements, 16) 2857 for rs.Next() { 2858 s, err = scanOnePaiement(rs) 2859 if err != nil { 2860 return nil, err 2861 } 2862 structs[s.Id] = s 2863 } 2864 if err = rs.Err(); err != nil { 2865 return nil, err 2866 } 2867 return structs, nil 2868 } 2869 2870 // Insert Paiement in the database and returns the item with id filled. 2871 func (item Paiement) Insert(tx DB) (out Paiement, err error) { 2872 row := tx.QueryRow(`INSERT INTO paiements ( 2873 id_facture,is_acompte,is_remboursement,in_bordereau,label_payeur,nom_banque,mode_paiement,numero,valeur,is_invalide,date_reglement,details 2874 ) VALUES ( 2875 $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12 2876 ) RETURNING 2877 id,id_facture,is_acompte,is_remboursement,in_bordereau,label_payeur,nom_banque,mode_paiement,numero,valeur,is_invalide,date_reglement,details; 2878 `, item.IdFacture, item.IsAcompte, item.IsRemboursement, item.InBordereau, item.LabelPayeur, item.NomBanque, item.ModePaiement, item.Numero, item.Valeur, item.IsInvalide, item.DateReglement, item.Details) 2879 return ScanPaiement(row) 2880 } 2881 2882 // Update Paiement in the database and returns the new version. 2883 func (item Paiement) Update(tx DB) (out Paiement, err error) { 2884 row := tx.QueryRow(`UPDATE paiements SET ( 2885 id_facture,is_acompte,is_remboursement,in_bordereau,label_payeur,nom_banque,mode_paiement,numero,valeur,is_invalide,date_reglement,details 2886 ) = ( 2887 $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 2888 ) WHERE id = $1 RETURNING 2889 id,id_facture,is_acompte,is_remboursement,in_bordereau,label_payeur,nom_banque,mode_paiement,numero,valeur,is_invalide,date_reglement,details; 2890 `, item.Id, item.IdFacture, item.IsAcompte, item.IsRemboursement, item.InBordereau, item.LabelPayeur, item.NomBanque, item.ModePaiement, item.Numero, item.Valeur, item.IsInvalide, item.DateReglement, item.Details) 2891 return ScanPaiement(row) 2892 } 2893 2894 // Deletes the Paiement and returns the item 2895 func DeletePaiementById(tx DB, id int64) (Paiement, error) { 2896 row := tx.QueryRow("DELETE FROM paiements WHERE id = $1 RETURNING *;", id) 2897 return ScanPaiement(row) 2898 } 2899 2900 // Deletes the Paiement in the database and returns the ids. 2901 func DeletePaiementsByIds(tx DB, ids ...int64) (Ids, error) { 2902 rows, err := tx.Query("DELETE FROM paiements WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 2903 if err != nil { 2904 return nil, err 2905 } 2906 return ScanIds(rows) 2907 } 2908 2909 func scanOneParticipant(row scanner) (Participant, error) { 2910 var s Participant 2911 err := row.Scan( 2912 &s.Id, 2913 &s.IdCamp, 2914 &s.IdPersonne, 2915 &s.IdFacture, 2916 &s.ListeAttente, 2917 &s.Remises, 2918 &s.OptionPrix, 2919 &s.Options, 2920 &s.DateHeure, 2921 &s.isSimple, 2922 ) 2923 return s, err 2924 } 2925 2926 func ScanParticipant(row *sql.Row) (Participant, error) { 2927 return scanOneParticipant(row) 2928 } 2929 2930 func SelectAllParticipants(tx DB) (Participants, error) { 2931 rows, err := tx.Query("SELECT * FROM participants") 2932 if err != nil { 2933 return nil, err 2934 } 2935 return ScanParticipants(rows) 2936 } 2937 2938 // SelectParticipant returns the entry matching id. 2939 func SelectParticipant(tx DB, id int64) (Participant, error) { 2940 row := tx.QueryRow("SELECT * FROM participants WHERE id = $1", id) 2941 return ScanParticipant(row) 2942 } 2943 2944 // SelectParticipants returns the entry matching the given ids. 2945 func SelectParticipants(tx DB, ids ...int64) (Participants, error) { 2946 rows, err := tx.Query("SELECT * FROM participants WHERE id = ANY($1)", pq.Int64Array(ids)) 2947 if err != nil { 2948 return nil, err 2949 } 2950 return ScanParticipants(rows) 2951 } 2952 2953 type Participants map[int64]Participant 2954 2955 func (m Participants) Ids() Ids { 2956 out := make(Ids, 0, len(m)) 2957 for i := range m { 2958 out = append(out, i) 2959 } 2960 return out 2961 } 2962 2963 func ScanParticipants(rs *sql.Rows) (Participants, error) { 2964 var ( 2965 s Participant 2966 err error 2967 ) 2968 defer func() { 2969 errClose := rs.Close() 2970 if err == nil { 2971 err = errClose 2972 } 2973 }() 2974 structs := make(Participants, 16) 2975 for rs.Next() { 2976 s, err = scanOneParticipant(rs) 2977 if err != nil { 2978 return nil, err 2979 } 2980 structs[s.Id] = s 2981 } 2982 if err = rs.Err(); err != nil { 2983 return nil, err 2984 } 2985 return structs, nil 2986 } 2987 2988 // Insert Participant in the database and returns the item with id filled. 2989 func (item Participant) Insert(tx DB) (out Participant, err error) { 2990 row := tx.QueryRow(`INSERT INTO participants ( 2991 id_camp,id_personne,id_facture,liste_attente,remises,option_prix,options,date_heure 2992 ) VALUES ( 2993 $1,$2,$3,$4,$5,$6,$7,$8 2994 ) RETURNING 2995 id,id_camp,id_personne,id_facture,liste_attente,remises,option_prix,options,date_heure,isSimple; 2996 `, item.IdCamp, item.IdPersonne, item.IdFacture, item.ListeAttente, item.Remises, item.OptionPrix, item.Options, item.DateHeure) 2997 return ScanParticipant(row) 2998 } 2999 3000 // Update Participant in the database and returns the new version. 3001 func (item Participant) Update(tx DB) (out Participant, err error) { 3002 row := tx.QueryRow(`UPDATE participants SET ( 3003 id_camp,id_personne,id_facture,liste_attente,remises,option_prix,options,date_heure 3004 ) = ( 3005 $2,$3,$4,$5,$6,$7,$8,$9 3006 ) WHERE id = $1 RETURNING 3007 id,id_camp,id_personne,id_facture,liste_attente,remises,option_prix,options,date_heure,isSimple; 3008 `, item.Id, item.IdCamp, item.IdPersonne, item.IdFacture, item.ListeAttente, item.Remises, item.OptionPrix, item.Options, item.DateHeure) 3009 return ScanParticipant(row) 3010 } 3011 3012 // Deletes the Participant and returns the item 3013 func DeleteParticipantById(tx DB, id int64) (Participant, error) { 3014 row := tx.QueryRow("DELETE FROM participants WHERE id = $1 RETURNING *;", id) 3015 return ScanParticipant(row) 3016 } 3017 3018 // Deletes the Participant in the database and returns the ids. 3019 func DeleteParticipantsByIds(tx DB, ids ...int64) (Ids, error) { 3020 rows, err := tx.Query("DELETE FROM participants WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3021 if err != nil { 3022 return nil, err 3023 } 3024 return ScanIds(rows) 3025 } 3026 3027 func scanOneParticipantEquipier(row scanner) (ParticipantEquipier, error) { 3028 var s ParticipantEquipier 3029 err := row.Scan( 3030 &s.IdParticipant, 3031 &s.IdEquipier, 3032 &s.IdGroupe, 3033 ) 3034 return s, err 3035 } 3036 3037 func ScanParticipantEquipier(row *sql.Row) (ParticipantEquipier, error) { 3038 return scanOneParticipantEquipier(row) 3039 } 3040 3041 func SelectAllParticipantEquipiers(tx DB) (ParticipantEquipiers, error) { 3042 rows, err := tx.Query("SELECT * FROM participant_equipiers") 3043 if err != nil { 3044 return nil, err 3045 } 3046 return ScanParticipantEquipiers(rows) 3047 } 3048 3049 type ParticipantEquipiers []ParticipantEquipier 3050 3051 func ScanParticipantEquipiers(rs *sql.Rows) (ParticipantEquipiers, error) { 3052 var ( 3053 s ParticipantEquipier 3054 err error 3055 ) 3056 defer func() { 3057 errClose := rs.Close() 3058 if err == nil { 3059 err = errClose 3060 } 3061 }() 3062 structs := make(ParticipantEquipiers, 0, 16) 3063 for rs.Next() { 3064 s, err = scanOneParticipantEquipier(rs) 3065 if err != nil { 3066 return nil, err 3067 } 3068 structs = append(structs, s) 3069 } 3070 if err = rs.Err(); err != nil { 3071 return nil, err 3072 } 3073 return structs, nil 3074 } 3075 3076 // Insert the links ParticipantEquipier in the database. 3077 func InsertManyParticipantEquipiers(tx *sql.Tx, items ...ParticipantEquipier) error { 3078 if len(items) == 0 { 3079 return nil 3080 } 3081 3082 stmt, err := tx.Prepare(pq.CopyIn("participant_equipiers", 3083 "id_participant", "id_equipier", "id_groupe", 3084 )) 3085 if err != nil { 3086 return err 3087 } 3088 3089 for _, item := range items { 3090 _, err = stmt.Exec(item.IdParticipant, item.IdEquipier, item.IdGroupe) 3091 if err != nil { 3092 return err 3093 } 3094 } 3095 3096 if _, err = stmt.Exec(); err != nil { 3097 return err 3098 } 3099 3100 if err = stmt.Close(); err != nil { 3101 return err 3102 } 3103 return nil 3104 } 3105 3106 // Delete the link ParticipantEquipier in the database. 3107 // Only the 'IdParticipant' 'IdEquipier' 'IdGroupe' fields are used. 3108 func (item ParticipantEquipier) Delete(tx DB) error { 3109 _, err := tx.Exec(`DELETE FROM participant_equipiers WHERE 3110 id_participant = $1 AND id_equipier = $2 AND id_groupe = $3;`, item.IdParticipant, item.IdEquipier, item.IdGroupe) 3111 return err 3112 } 3113 3114 func scanOneParticipantsimple(row scanner) (Participantsimple, error) { 3115 var s Participantsimple 3116 err := row.Scan( 3117 &s.Id, 3118 &s.IdPersonne, 3119 &s.IdCamp, 3120 &s.DateHeure, 3121 &s.Info, 3122 &s.isSimple, 3123 ) 3124 return s, err 3125 } 3126 3127 func ScanParticipantsimple(row *sql.Row) (Participantsimple, error) { 3128 return scanOneParticipantsimple(row) 3129 } 3130 3131 func SelectAllParticipantsimples(tx DB) (Participantsimples, error) { 3132 rows, err := tx.Query("SELECT * FROM participantsimples") 3133 if err != nil { 3134 return nil, err 3135 } 3136 return ScanParticipantsimples(rows) 3137 } 3138 3139 // SelectParticipantsimple returns the entry matching id. 3140 func SelectParticipantsimple(tx DB, id int64) (Participantsimple, error) { 3141 row := tx.QueryRow("SELECT * FROM participantsimples WHERE id = $1", id) 3142 return ScanParticipantsimple(row) 3143 } 3144 3145 // SelectParticipantsimples returns the entry matching the given ids. 3146 func SelectParticipantsimples(tx DB, ids ...int64) (Participantsimples, error) { 3147 rows, err := tx.Query("SELECT * FROM participantsimples WHERE id = ANY($1)", pq.Int64Array(ids)) 3148 if err != nil { 3149 return nil, err 3150 } 3151 return ScanParticipantsimples(rows) 3152 } 3153 3154 type Participantsimples map[int64]Participantsimple 3155 3156 func (m Participantsimples) Ids() Ids { 3157 out := make(Ids, 0, len(m)) 3158 for i := range m { 3159 out = append(out, i) 3160 } 3161 return out 3162 } 3163 3164 func ScanParticipantsimples(rs *sql.Rows) (Participantsimples, error) { 3165 var ( 3166 s Participantsimple 3167 err error 3168 ) 3169 defer func() { 3170 errClose := rs.Close() 3171 if err == nil { 3172 err = errClose 3173 } 3174 }() 3175 structs := make(Participantsimples, 16) 3176 for rs.Next() { 3177 s, err = scanOneParticipantsimple(rs) 3178 if err != nil { 3179 return nil, err 3180 } 3181 structs[s.Id] = s 3182 } 3183 if err = rs.Err(); err != nil { 3184 return nil, err 3185 } 3186 return structs, nil 3187 } 3188 3189 // Insert Participantsimple in the database and returns the item with id filled. 3190 func (item Participantsimple) Insert(tx DB) (out Participantsimple, err error) { 3191 row := tx.QueryRow(`INSERT INTO participantsimples ( 3192 id_personne,id_camp,date_heure,info 3193 ) VALUES ( 3194 $1,$2,$3,$4 3195 ) RETURNING 3196 id,id_personne,id_camp,date_heure,info,isSimple; 3197 `, item.IdPersonne, item.IdCamp, item.DateHeure, item.Info) 3198 return ScanParticipantsimple(row) 3199 } 3200 3201 // Update Participantsimple in the database and returns the new version. 3202 func (item Participantsimple) Update(tx DB) (out Participantsimple, err error) { 3203 row := tx.QueryRow(`UPDATE participantsimples SET ( 3204 id_personne,id_camp,date_heure,info 3205 ) = ( 3206 $2,$3,$4,$5 3207 ) WHERE id = $1 RETURNING 3208 id,id_personne,id_camp,date_heure,info,isSimple; 3209 `, item.Id, item.IdPersonne, item.IdCamp, item.DateHeure, item.Info) 3210 return ScanParticipantsimple(row) 3211 } 3212 3213 // Deletes the Participantsimple and returns the item 3214 func DeleteParticipantsimpleById(tx DB, id int64) (Participantsimple, error) { 3215 row := tx.QueryRow("DELETE FROM participantsimples WHERE id = $1 RETURNING *;", id) 3216 return ScanParticipantsimple(row) 3217 } 3218 3219 // Deletes the Participantsimple in the database and returns the ids. 3220 func DeleteParticipantsimplesByIds(tx DB, ids ...int64) (Ids, error) { 3221 rows, err := tx.Query("DELETE FROM participantsimples WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3222 if err != nil { 3223 return nil, err 3224 } 3225 return ScanIds(rows) 3226 } 3227 3228 func scanOnePersonne(row scanner) (Personne, error) { 3229 var s Personne 3230 err := row.Scan( 3231 &s.Id, 3232 &s.Nom, 3233 &s.NomJeuneFille, 3234 &s.Prenom, 3235 &s.DateNaissance, 3236 &s.VilleNaissance, 3237 &s.DepartementNaissance, 3238 &s.Sexe, 3239 &s.Tels, 3240 &s.Mail, 3241 &s.Adresse, 3242 &s.CodePostal, 3243 &s.Ville, 3244 &s.Pays, 3245 &s.SecuriteSociale, 3246 &s.Profession, 3247 &s.Etudiant, 3248 &s.Fonctionnaire, 3249 &s.VersionPapier, 3250 &s.PubHiver, 3251 &s.PubEte, 3252 &s.EchoRocher, 3253 &s.RangMembreAsso, 3254 &s.QuotientFamilial, 3255 &s.Cotisation, 3256 &s.Eonews, 3257 &s.FicheSanitaire, 3258 &s.IsTemporaire, 3259 ) 3260 return s, err 3261 } 3262 3263 func ScanPersonne(row *sql.Row) (Personne, error) { 3264 return scanOnePersonne(row) 3265 } 3266 3267 func SelectAllPersonnes(tx DB) (Personnes, error) { 3268 rows, err := tx.Query("SELECT * FROM personnes") 3269 if err != nil { 3270 return nil, err 3271 } 3272 return ScanPersonnes(rows) 3273 } 3274 3275 // SelectPersonne returns the entry matching id. 3276 func SelectPersonne(tx DB, id int64) (Personne, error) { 3277 row := tx.QueryRow("SELECT * FROM personnes WHERE id = $1", id) 3278 return ScanPersonne(row) 3279 } 3280 3281 // SelectPersonnes returns the entry matching the given ids. 3282 func SelectPersonnes(tx DB, ids ...int64) (Personnes, error) { 3283 rows, err := tx.Query("SELECT * FROM personnes WHERE id = ANY($1)", pq.Int64Array(ids)) 3284 if err != nil { 3285 return nil, err 3286 } 3287 return ScanPersonnes(rows) 3288 } 3289 3290 type Personnes map[int64]Personne 3291 3292 func (m Personnes) Ids() Ids { 3293 out := make(Ids, 0, len(m)) 3294 for i := range m { 3295 out = append(out, i) 3296 } 3297 return out 3298 } 3299 3300 func ScanPersonnes(rs *sql.Rows) (Personnes, error) { 3301 var ( 3302 s Personne 3303 err error 3304 ) 3305 defer func() { 3306 errClose := rs.Close() 3307 if err == nil { 3308 err = errClose 3309 } 3310 }() 3311 structs := make(Personnes, 16) 3312 for rs.Next() { 3313 s, err = scanOnePersonne(rs) 3314 if err != nil { 3315 return nil, err 3316 } 3317 structs[s.Id] = s 3318 } 3319 if err = rs.Err(); err != nil { 3320 return nil, err 3321 } 3322 return structs, nil 3323 } 3324 3325 // Insert Personne in the database and returns the item with id filled. 3326 func (item Personne) Insert(tx DB) (out Personne, err error) { 3327 row := tx.QueryRow(`INSERT INTO personnes ( 3328 nom,nom_jeune_fille,prenom,date_naissance,ville_naissance,departement_naissance,sexe,tels,mail,adresse,code_postal,ville,pays,securite_sociale,profession,etudiant,fonctionnaire,version_papier,pub_hiver,pub_ete,echo_rocher,rang_membre_asso,quotient_familial,cotisation,eonews,fiche_sanitaire,is_temporaire 3329 ) VALUES ( 3330 $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27 3331 ) RETURNING 3332 id,nom,nom_jeune_fille,prenom,date_naissance,ville_naissance,departement_naissance,sexe,tels,mail,adresse,code_postal,ville,pays,securite_sociale,profession,etudiant,fonctionnaire,version_papier,pub_hiver,pub_ete,echo_rocher,rang_membre_asso,quotient_familial,cotisation,eonews,fiche_sanitaire,is_temporaire; 3333 `, item.Nom, item.NomJeuneFille, item.Prenom, item.DateNaissance, item.VilleNaissance, item.DepartementNaissance, item.Sexe, item.Tels, item.Mail, item.Adresse, item.CodePostal, item.Ville, item.Pays, item.SecuriteSociale, item.Profession, item.Etudiant, item.Fonctionnaire, item.VersionPapier, item.PubHiver, item.PubEte, item.EchoRocher, item.RangMembreAsso, item.QuotientFamilial, item.Cotisation, item.Eonews, item.FicheSanitaire, item.IsTemporaire) 3334 return ScanPersonne(row) 3335 } 3336 3337 // Update Personne in the database and returns the new version. 3338 func (item Personne) Update(tx DB) (out Personne, err error) { 3339 row := tx.QueryRow(`UPDATE personnes SET ( 3340 nom,nom_jeune_fille,prenom,date_naissance,ville_naissance,departement_naissance,sexe,tels,mail,adresse,code_postal,ville,pays,securite_sociale,profession,etudiant,fonctionnaire,version_papier,pub_hiver,pub_ete,echo_rocher,rang_membre_asso,quotient_familial,cotisation,eonews,fiche_sanitaire,is_temporaire 3341 ) = ( 3342 $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28 3343 ) WHERE id = $1 RETURNING 3344 id,nom,nom_jeune_fille,prenom,date_naissance,ville_naissance,departement_naissance,sexe,tels,mail,adresse,code_postal,ville,pays,securite_sociale,profession,etudiant,fonctionnaire,version_papier,pub_hiver,pub_ete,echo_rocher,rang_membre_asso,quotient_familial,cotisation,eonews,fiche_sanitaire,is_temporaire; 3345 `, item.Id, item.Nom, item.NomJeuneFille, item.Prenom, item.DateNaissance, item.VilleNaissance, item.DepartementNaissance, item.Sexe, item.Tels, item.Mail, item.Adresse, item.CodePostal, item.Ville, item.Pays, item.SecuriteSociale, item.Profession, item.Etudiant, item.Fonctionnaire, item.VersionPapier, item.PubHiver, item.PubEte, item.EchoRocher, item.RangMembreAsso, item.QuotientFamilial, item.Cotisation, item.Eonews, item.FicheSanitaire, item.IsTemporaire) 3346 return ScanPersonne(row) 3347 } 3348 3349 // Deletes the Personne and returns the item 3350 func DeletePersonneById(tx DB, id int64) (Personne, error) { 3351 row := tx.QueryRow("DELETE FROM personnes WHERE id = $1 RETURNING *;", id) 3352 return ScanPersonne(row) 3353 } 3354 3355 // Deletes the Personne in the database and returns the ids. 3356 func DeletePersonnesByIds(tx DB, ids ...int64) (Ids, error) { 3357 rows, err := tx.Query("DELETE FROM personnes WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3358 if err != nil { 3359 return nil, err 3360 } 3361 return ScanIds(rows) 3362 } 3363 3364 func scanOneSondage(row scanner) (Sondage, error) { 3365 var s Sondage 3366 err := row.Scan( 3367 &s.Id, 3368 &s.IdCamp, 3369 &s.IdFacture, 3370 &s.Modified, 3371 &s.InfosAvantSejour, 3372 &s.InfosPendantSejour, 3373 &s.Hebergement, 3374 &s.Activites, 3375 &s.Theme, 3376 &s.Nourriture, 3377 &s.Hygiene, 3378 &s.Ambiance, 3379 &s.Ressenti, 3380 &s.MessageEnfant, 3381 &s.MessageResponsable, 3382 ) 3383 return s, err 3384 } 3385 3386 func ScanSondage(row *sql.Row) (Sondage, error) { 3387 return scanOneSondage(row) 3388 } 3389 3390 func SelectAllSondages(tx DB) (Sondages, error) { 3391 rows, err := tx.Query("SELECT * FROM sondages") 3392 if err != nil { 3393 return nil, err 3394 } 3395 return ScanSondages(rows) 3396 } 3397 3398 // SelectSondage returns the entry matching id. 3399 func SelectSondage(tx DB, id int64) (Sondage, error) { 3400 row := tx.QueryRow("SELECT * FROM sondages WHERE id = $1", id) 3401 return ScanSondage(row) 3402 } 3403 3404 // SelectSondages returns the entry matching the given ids. 3405 func SelectSondages(tx DB, ids ...int64) (Sondages, error) { 3406 rows, err := tx.Query("SELECT * FROM sondages WHERE id = ANY($1)", pq.Int64Array(ids)) 3407 if err != nil { 3408 return nil, err 3409 } 3410 return ScanSondages(rows) 3411 } 3412 3413 type Sondages map[int64]Sondage 3414 3415 func (m Sondages) Ids() Ids { 3416 out := make(Ids, 0, len(m)) 3417 for i := range m { 3418 out = append(out, i) 3419 } 3420 return out 3421 } 3422 3423 func ScanSondages(rs *sql.Rows) (Sondages, error) { 3424 var ( 3425 s Sondage 3426 err error 3427 ) 3428 defer func() { 3429 errClose := rs.Close() 3430 if err == nil { 3431 err = errClose 3432 } 3433 }() 3434 structs := make(Sondages, 16) 3435 for rs.Next() { 3436 s, err = scanOneSondage(rs) 3437 if err != nil { 3438 return nil, err 3439 } 3440 structs[s.Id] = s 3441 } 3442 if err = rs.Err(); err != nil { 3443 return nil, err 3444 } 3445 return structs, nil 3446 } 3447 3448 // Insert Sondage in the database and returns the item with id filled. 3449 func (item Sondage) Insert(tx DB) (out Sondage, err error) { 3450 row := tx.QueryRow(`INSERT INTO sondages ( 3451 id_camp,id_facture,modified,infos_avant_sejour,infos_pendant_sejour,hebergement,activites,theme,nourriture,hygiene,ambiance,ressenti,message_enfant,message_responsable 3452 ) VALUES ( 3453 $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14 3454 ) RETURNING 3455 id,id_camp,id_facture,modified,infos_avant_sejour,infos_pendant_sejour,hebergement,activites,theme,nourriture,hygiene,ambiance,ressenti,message_enfant,message_responsable; 3456 `, item.IdCamp, item.IdFacture, item.Modified, item.InfosAvantSejour, item.InfosPendantSejour, item.Hebergement, item.Activites, item.Theme, item.Nourriture, item.Hygiene, item.Ambiance, item.Ressenti, item.MessageEnfant, item.MessageResponsable) 3457 return ScanSondage(row) 3458 } 3459 3460 // Update Sondage in the database and returns the new version. 3461 func (item Sondage) Update(tx DB) (out Sondage, err error) { 3462 row := tx.QueryRow(`UPDATE sondages SET ( 3463 id_camp,id_facture,modified,infos_avant_sejour,infos_pendant_sejour,hebergement,activites,theme,nourriture,hygiene,ambiance,ressenti,message_enfant,message_responsable 3464 ) = ( 3465 $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15 3466 ) WHERE id = $1 RETURNING 3467 id,id_camp,id_facture,modified,infos_avant_sejour,infos_pendant_sejour,hebergement,activites,theme,nourriture,hygiene,ambiance,ressenti,message_enfant,message_responsable; 3468 `, item.Id, item.IdCamp, item.IdFacture, item.Modified, item.InfosAvantSejour, item.InfosPendantSejour, item.Hebergement, item.Activites, item.Theme, item.Nourriture, item.Hygiene, item.Ambiance, item.Ressenti, item.MessageEnfant, item.MessageResponsable) 3469 return ScanSondage(row) 3470 } 3471 3472 // Deletes the Sondage and returns the item 3473 func DeleteSondageById(tx DB, id int64) (Sondage, error) { 3474 row := tx.QueryRow("DELETE FROM sondages WHERE id = $1 RETURNING *;", id) 3475 return ScanSondage(row) 3476 } 3477 3478 // Deletes the Sondage in the database and returns the ids. 3479 func DeleteSondagesByIds(tx DB, ids ...int64) (Ids, error) { 3480 rows, err := tx.Query("DELETE FROM sondages WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3481 if err != nil { 3482 return nil, err 3483 } 3484 return ScanIds(rows) 3485 } 3486 3487 func scanOneStructureaide(row scanner) (Structureaide, error) { 3488 var s Structureaide 3489 err := row.Scan( 3490 &s.Id, 3491 &s.Nom, 3492 &s.Immatriculation, 3493 &s.Adresse, 3494 &s.CodePostal, 3495 &s.Ville, 3496 &s.Telephone, 3497 &s.Info, 3498 ) 3499 return s, err 3500 } 3501 3502 func ScanStructureaide(row *sql.Row) (Structureaide, error) { 3503 return scanOneStructureaide(row) 3504 } 3505 3506 func SelectAllStructureaides(tx DB) (Structureaides, error) { 3507 rows, err := tx.Query("SELECT * FROM structureaides") 3508 if err != nil { 3509 return nil, err 3510 } 3511 return ScanStructureaides(rows) 3512 } 3513 3514 // SelectStructureaide returns the entry matching id. 3515 func SelectStructureaide(tx DB, id int64) (Structureaide, error) { 3516 row := tx.QueryRow("SELECT * FROM structureaides WHERE id = $1", id) 3517 return ScanStructureaide(row) 3518 } 3519 3520 // SelectStructureaides returns the entry matching the given ids. 3521 func SelectStructureaides(tx DB, ids ...int64) (Structureaides, error) { 3522 rows, err := tx.Query("SELECT * FROM structureaides WHERE id = ANY($1)", pq.Int64Array(ids)) 3523 if err != nil { 3524 return nil, err 3525 } 3526 return ScanStructureaides(rows) 3527 } 3528 3529 type Structureaides map[int64]Structureaide 3530 3531 func (m Structureaides) Ids() Ids { 3532 out := make(Ids, 0, len(m)) 3533 for i := range m { 3534 out = append(out, i) 3535 } 3536 return out 3537 } 3538 3539 func ScanStructureaides(rs *sql.Rows) (Structureaides, error) { 3540 var ( 3541 s Structureaide 3542 err error 3543 ) 3544 defer func() { 3545 errClose := rs.Close() 3546 if err == nil { 3547 err = errClose 3548 } 3549 }() 3550 structs := make(Structureaides, 16) 3551 for rs.Next() { 3552 s, err = scanOneStructureaide(rs) 3553 if err != nil { 3554 return nil, err 3555 } 3556 structs[s.Id] = s 3557 } 3558 if err = rs.Err(); err != nil { 3559 return nil, err 3560 } 3561 return structs, nil 3562 } 3563 3564 // Insert Structureaide in the database and returns the item with id filled. 3565 func (item Structureaide) Insert(tx DB) (out Structureaide, err error) { 3566 row := tx.QueryRow(`INSERT INTO structureaides ( 3567 nom,immatriculation,adresse,code_postal,ville,telephone,info 3568 ) VALUES ( 3569 $1,$2,$3,$4,$5,$6,$7 3570 ) RETURNING 3571 id,nom,immatriculation,adresse,code_postal,ville,telephone,info; 3572 `, item.Nom, item.Immatriculation, item.Adresse, item.CodePostal, item.Ville, item.Telephone, item.Info) 3573 return ScanStructureaide(row) 3574 } 3575 3576 // Update Structureaide in the database and returns the new version. 3577 func (item Structureaide) Update(tx DB) (out Structureaide, err error) { 3578 row := tx.QueryRow(`UPDATE structureaides SET ( 3579 nom,immatriculation,adresse,code_postal,ville,telephone,info 3580 ) = ( 3581 $2,$3,$4,$5,$6,$7,$8 3582 ) WHERE id = $1 RETURNING 3583 id,nom,immatriculation,adresse,code_postal,ville,telephone,info; 3584 `, item.Id, item.Nom, item.Immatriculation, item.Adresse, item.CodePostal, item.Ville, item.Telephone, item.Info) 3585 return ScanStructureaide(row) 3586 } 3587 3588 // Deletes the Structureaide and returns the item 3589 func DeleteStructureaideById(tx DB, id int64) (Structureaide, error) { 3590 row := tx.QueryRow("DELETE FROM structureaides WHERE id = $1 RETURNING *;", id) 3591 return ScanStructureaide(row) 3592 } 3593 3594 // Deletes the Structureaide in the database and returns the ids. 3595 func DeleteStructureaidesByIds(tx DB, ids ...int64) (Ids, error) { 3596 rows, err := tx.Query("DELETE FROM structureaides WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3597 if err != nil { 3598 return nil, err 3599 } 3600 return ScanIds(rows) 3601 } 3602 3603 func scanOneUser(row scanner) (User, error) { 3604 var s User 3605 err := row.Scan( 3606 &s.Id, 3607 &s.Label, 3608 &s.Mdp, 3609 &s.IsAdmin, 3610 &s.Modules, 3611 ) 3612 return s, err 3613 } 3614 3615 func ScanUser(row *sql.Row) (User, error) { 3616 return scanOneUser(row) 3617 } 3618 3619 func SelectAllUsers(tx DB) (Users, error) { 3620 rows, err := tx.Query("SELECT * FROM users") 3621 if err != nil { 3622 return nil, err 3623 } 3624 return ScanUsers(rows) 3625 } 3626 3627 // SelectUser returns the entry matching id. 3628 func SelectUser(tx DB, id int64) (User, error) { 3629 row := tx.QueryRow("SELECT * FROM users WHERE id = $1", id) 3630 return ScanUser(row) 3631 } 3632 3633 // SelectUsers returns the entry matching the given ids. 3634 func SelectUsers(tx DB, ids ...int64) (Users, error) { 3635 rows, err := tx.Query("SELECT * FROM users WHERE id = ANY($1)", pq.Int64Array(ids)) 3636 if err != nil { 3637 return nil, err 3638 } 3639 return ScanUsers(rows) 3640 } 3641 3642 type Users map[int64]User 3643 3644 func (m Users) Ids() Ids { 3645 out := make(Ids, 0, len(m)) 3646 for i := range m { 3647 out = append(out, i) 3648 } 3649 return out 3650 } 3651 3652 func ScanUsers(rs *sql.Rows) (Users, error) { 3653 var ( 3654 s User 3655 err error 3656 ) 3657 defer func() { 3658 errClose := rs.Close() 3659 if err == nil { 3660 err = errClose 3661 } 3662 }() 3663 structs := make(Users, 16) 3664 for rs.Next() { 3665 s, err = scanOneUser(rs) 3666 if err != nil { 3667 return nil, err 3668 } 3669 structs[s.Id] = s 3670 } 3671 if err = rs.Err(); err != nil { 3672 return nil, err 3673 } 3674 return structs, nil 3675 } 3676 3677 // Insert User in the database and returns the item with id filled. 3678 func (item User) Insert(tx DB) (out User, err error) { 3679 row := tx.QueryRow(`INSERT INTO users ( 3680 label,mdp,is_admin,modules 3681 ) VALUES ( 3682 $1,$2,$3,$4 3683 ) RETURNING 3684 id,label,mdp,is_admin,modules; 3685 `, item.Label, item.Mdp, item.IsAdmin, item.Modules) 3686 return ScanUser(row) 3687 } 3688 3689 // Update User in the database and returns the new version. 3690 func (item User) Update(tx DB) (out User, err error) { 3691 row := tx.QueryRow(`UPDATE users SET ( 3692 label,mdp,is_admin,modules 3693 ) = ( 3694 $2,$3,$4,$5 3695 ) WHERE id = $1 RETURNING 3696 id,label,mdp,is_admin,modules; 3697 `, item.Id, item.Label, item.Mdp, item.IsAdmin, item.Modules) 3698 return ScanUser(row) 3699 } 3700 3701 // Deletes the User and returns the item 3702 func DeleteUserById(tx DB, id int64) (User, error) { 3703 row := tx.QueryRow("DELETE FROM users WHERE id = $1 RETURNING *;", id) 3704 return ScanUser(row) 3705 } 3706 3707 // Deletes the User in the database and returns the ids. 3708 func DeleteUsersByIds(tx DB, ids ...int64) (Ids, error) { 3709 rows, err := tx.Query("DELETE FROM users WHERE id = ANY($1) RETURNING id", pq.Int64Array(ids)) 3710 if err != nil { 3711 return nil, err 3712 } 3713 return ScanIds(rows) 3714 } 3715 3716 func SelectAidesByIdStructureaides(tx DB, idStructureaides ...int64) (Aides, error) { 3717 rows, err := tx.Query("SELECT * FROM aides WHERE id_structureaide = ANY($1)", pq.Int64Array(idStructureaides)) 3718 if err != nil { 3719 return nil, err 3720 } 3721 return ScanAides(rows) 3722 } 3723 3724 func DeleteAidesByIdStructureaides(tx DB, idStructureaides ...int64) (Ids, error) { 3725 rows, err := tx.Query("DELETE FROM aides WHERE id_structureaide = ANY($1) RETURNING id", pq.Int64Array(idStructureaides)) 3726 if err != nil { 3727 return nil, err 3728 } 3729 return ScanIds(rows) 3730 } 3731 3732 func SelectAidesByIdParticipants(tx DB, idParticipants ...int64) (Aides, error) { 3733 rows, err := tx.Query("SELECT * FROM aides WHERE id_participant = ANY($1)", pq.Int64Array(idParticipants)) 3734 if err != nil { 3735 return nil, err 3736 } 3737 return ScanAides(rows) 3738 } 3739 3740 func DeleteAidesByIdParticipants(tx DB, idParticipants ...int64) (Ids, error) { 3741 rows, err := tx.Query("DELETE FROM aides WHERE id_participant = ANY($1) RETURNING id", pq.Int64Array(idParticipants)) 3742 if err != nil { 3743 return nil, err 3744 } 3745 return ScanIds(rows) 3746 } 3747 3748 func SelectCampContraintesByIdCamps(tx DB, idCamps ...int64) (CampContraintes, error) { 3749 rows, err := tx.Query("SELECT * FROM camp_contraintes WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 3750 if err != nil { 3751 return nil, err 3752 } 3753 return ScanCampContraintes(rows) 3754 } 3755 3756 func DeleteCampContraintesByIdCamps(tx DB, idCamps ...int64) (CampContraintes, error) { 3757 rows, err := tx.Query("DELETE FROM camp_contraintes WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 3758 if err != nil { 3759 return nil, err 3760 } 3761 return ScanCampContraintes(rows) 3762 } 3763 3764 func SelectCampContraintesByIdContraintes(tx DB, idContraintes ...int64) (CampContraintes, error) { 3765 rows, err := tx.Query("SELECT * FROM camp_contraintes WHERE id_contrainte = ANY($1)", pq.Int64Array(idContraintes)) 3766 if err != nil { 3767 return nil, err 3768 } 3769 return ScanCampContraintes(rows) 3770 } 3771 3772 func DeleteCampContraintesByIdContraintes(tx DB, idContraintes ...int64) (CampContraintes, error) { 3773 rows, err := tx.Query("DELETE FROM camp_contraintes WHERE id_contrainte = ANY($1) RETURNING *", pq.Int64Array(idContraintes)) 3774 if err != nil { 3775 return nil, err 3776 } 3777 return ScanCampContraintes(rows) 3778 } 3779 3780 // ByIdCamp returns a map with 'IdCamp' as keys. 3781 func (items CampContraintes) ByIdCamp() map[int64]CampContraintes { 3782 out := make(map[int64]CampContraintes) 3783 for _, target := range items { 3784 out[target.IdCamp] = append(out[target.IdCamp], target) 3785 } 3786 return out 3787 } 3788 3789 // ByIdContrainte returns a map with 'IdContrainte' as keys. 3790 func (items CampContraintes) ByIdContrainte() map[int64]CampContraintes { 3791 out := make(map[int64]CampContraintes) 3792 for _, target := range items { 3793 out[target.IdContrainte] = append(out[target.IdContrainte], target) 3794 } 3795 return out 3796 } 3797 3798 // SelectContenuDocumentByIdDocument return zero or one item, thanks to a UNIQUE constraint 3799 func SelectContenuDocumentByIdDocument(tx DB, idDocument int64) (item ContenuDocument, found bool, err error) { 3800 row := tx.QueryRow("SELECT * FROM contenu_documents WHERE id_document = $1", idDocument) 3801 item, err = ScanContenuDocument(row) 3802 if err == sql.ErrNoRows { 3803 return item, false, nil 3804 } 3805 return item, true, err 3806 } 3807 3808 func SelectContenuDocumentsByIdDocuments(tx DB, idDocuments ...int64) (ContenuDocuments, error) { 3809 rows, err := tx.Query("SELECT * FROM contenu_documents WHERE id_document = ANY($1)", pq.Int64Array(idDocuments)) 3810 if err != nil { 3811 return nil, err 3812 } 3813 return ScanContenuDocuments(rows) 3814 } 3815 3816 func DeleteContenuDocumentsByIdDocuments(tx DB, idDocuments ...int64) (ContenuDocuments, error) { 3817 rows, err := tx.Query("DELETE FROM contenu_documents WHERE id_document = ANY($1) RETURNING *", pq.Int64Array(idDocuments)) 3818 if err != nil { 3819 return nil, err 3820 } 3821 return ScanContenuDocuments(rows) 3822 } 3823 3824 // ByIdDocument returns a map with 'IdDocument' as keys. 3825 func (items ContenuDocuments) ByIdDocument() map[int64]ContenuDocument { 3826 out := make(map[int64]ContenuDocument, len(items)) 3827 for _, target := range items { 3828 out[target.IdDocument] = target 3829 } 3830 return out 3831 } 3832 3833 func SelectContraintesByIdPersonnes(tx DB, idPersonnes ...int64) (Contraintes, error) { 3834 rows, err := tx.Query("SELECT * FROM contraintes WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 3835 if err != nil { 3836 return nil, err 3837 } 3838 return ScanContraintes(rows) 3839 } 3840 3841 func DeleteContraintesByIdPersonnes(tx DB, idPersonnes ...int64) (Ids, error) { 3842 rows, err := tx.Query("DELETE FROM contraintes WHERE id_personne = ANY($1) RETURNING id", pq.Int64Array(idPersonnes)) 3843 if err != nil { 3844 return nil, err 3845 } 3846 return ScanIds(rows) 3847 } 3848 3849 func SelectContraintesByIdDocuments(tx DB, idDocuments ...int64) (Contraintes, error) { 3850 rows, err := tx.Query("SELECT * FROM contraintes WHERE id_document = ANY($1)", pq.Int64Array(idDocuments)) 3851 if err != nil { 3852 return nil, err 3853 } 3854 return ScanContraintes(rows) 3855 } 3856 3857 func DeleteContraintesByIdDocuments(tx DB, idDocuments ...int64) (Ids, error) { 3858 rows, err := tx.Query("DELETE FROM contraintes WHERE id_document = ANY($1) RETURNING id", pq.Int64Array(idDocuments)) 3859 if err != nil { 3860 return nil, err 3861 } 3862 return ScanIds(rows) 3863 } 3864 3865 // SelectDocumentAideByIdDocument return zero or one item, thanks to a UNIQUE constraint 3866 func SelectDocumentAideByIdDocument(tx DB, idDocument int64) (item DocumentAide, found bool, err error) { 3867 row := tx.QueryRow("SELECT * FROM document_aides WHERE id_document = $1", idDocument) 3868 item, err = ScanDocumentAide(row) 3869 if err == sql.ErrNoRows { 3870 return item, false, nil 3871 } 3872 return item, true, err 3873 } 3874 3875 func SelectDocumentAidesByIdDocuments(tx DB, idDocuments ...int64) (DocumentAides, error) { 3876 rows, err := tx.Query("SELECT * FROM document_aides WHERE id_document = ANY($1)", pq.Int64Array(idDocuments)) 3877 if err != nil { 3878 return nil, err 3879 } 3880 return ScanDocumentAides(rows) 3881 } 3882 3883 func DeleteDocumentAidesByIdDocuments(tx DB, idDocuments ...int64) (DocumentAides, error) { 3884 rows, err := tx.Query("DELETE FROM document_aides WHERE id_document = ANY($1) RETURNING *", pq.Int64Array(idDocuments)) 3885 if err != nil { 3886 return nil, err 3887 } 3888 return ScanDocumentAides(rows) 3889 } 3890 3891 func SelectDocumentAidesByIdAides(tx DB, idAides ...int64) (DocumentAides, error) { 3892 rows, err := tx.Query("SELECT * FROM document_aides WHERE id_aide = ANY($1)", pq.Int64Array(idAides)) 3893 if err != nil { 3894 return nil, err 3895 } 3896 return ScanDocumentAides(rows) 3897 } 3898 3899 func DeleteDocumentAidesByIdAides(tx DB, idAides ...int64) (DocumentAides, error) { 3900 rows, err := tx.Query("DELETE FROM document_aides WHERE id_aide = ANY($1) RETURNING *", pq.Int64Array(idAides)) 3901 if err != nil { 3902 return nil, err 3903 } 3904 return ScanDocumentAides(rows) 3905 } 3906 3907 // ByIdDocument returns a map with 'IdDocument' as keys. 3908 func (items DocumentAides) ByIdDocument() map[int64]DocumentAide { 3909 out := make(map[int64]DocumentAide, len(items)) 3910 for _, target := range items { 3911 out[target.IdDocument] = target 3912 } 3913 return out 3914 } 3915 3916 // ByIdAide returns a map with 'IdAide' as keys. 3917 func (items DocumentAides) ByIdAide() map[int64]DocumentAides { 3918 out := make(map[int64]DocumentAides) 3919 for _, target := range items { 3920 out[target.IdAide] = append(out[target.IdAide], target) 3921 } 3922 return out 3923 } 3924 3925 // SelectDocumentCampByIdDocument return zero or one item, thanks to a UNIQUE constraint 3926 func SelectDocumentCampByIdDocument(tx DB, idDocument int64) (item DocumentCamp, found bool, err error) { 3927 row := tx.QueryRow("SELECT * FROM document_camps WHERE id_document = $1", idDocument) 3928 item, err = ScanDocumentCamp(row) 3929 if err == sql.ErrNoRows { 3930 return item, false, nil 3931 } 3932 return item, true, err 3933 } 3934 3935 func SelectDocumentCampsByIdDocuments(tx DB, idDocuments ...int64) (DocumentCamps, error) { 3936 rows, err := tx.Query("SELECT * FROM document_camps WHERE id_document = ANY($1)", pq.Int64Array(idDocuments)) 3937 if err != nil { 3938 return nil, err 3939 } 3940 return ScanDocumentCamps(rows) 3941 } 3942 3943 func DeleteDocumentCampsByIdDocuments(tx DB, idDocuments ...int64) (DocumentCamps, error) { 3944 rows, err := tx.Query("DELETE FROM document_camps WHERE id_document = ANY($1) RETURNING *", pq.Int64Array(idDocuments)) 3945 if err != nil { 3946 return nil, err 3947 } 3948 return ScanDocumentCamps(rows) 3949 } 3950 3951 func SelectDocumentCampsByIdCamps(tx DB, idCamps ...int64) (DocumentCamps, error) { 3952 rows, err := tx.Query("SELECT * FROM document_camps WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 3953 if err != nil { 3954 return nil, err 3955 } 3956 return ScanDocumentCamps(rows) 3957 } 3958 3959 func DeleteDocumentCampsByIdCamps(tx DB, idCamps ...int64) (DocumentCamps, error) { 3960 rows, err := tx.Query("DELETE FROM document_camps WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 3961 if err != nil { 3962 return nil, err 3963 } 3964 return ScanDocumentCamps(rows) 3965 } 3966 3967 // ByIdDocument returns a map with 'IdDocument' as keys. 3968 func (items DocumentCamps) ByIdDocument() map[int64]DocumentCamp { 3969 out := make(map[int64]DocumentCamp, len(items)) 3970 for _, target := range items { 3971 out[target.IdDocument] = target 3972 } 3973 return out 3974 } 3975 3976 // ByIdCamp returns a map with 'IdCamp' as keys. 3977 func (items DocumentCamps) ByIdCamp() map[int64]DocumentCamps { 3978 out := make(map[int64]DocumentCamps) 3979 for _, target := range items { 3980 out[target.IdCamp] = append(out[target.IdCamp], target) 3981 } 3982 return out 3983 } 3984 3985 // SelectDocumentPersonneByIdDocument return zero or one item, thanks to a UNIQUE constraint 3986 func SelectDocumentPersonneByIdDocument(tx DB, idDocument int64) (item DocumentPersonne, found bool, err error) { 3987 row := tx.QueryRow("SELECT * FROM document_personnes WHERE id_document = $1", idDocument) 3988 item, err = ScanDocumentPersonne(row) 3989 if err == sql.ErrNoRows { 3990 return item, false, nil 3991 } 3992 return item, true, err 3993 } 3994 3995 func SelectDocumentPersonnesByIdDocuments(tx DB, idDocuments ...int64) (DocumentPersonnes, error) { 3996 rows, err := tx.Query("SELECT * FROM document_personnes WHERE id_document = ANY($1)", pq.Int64Array(idDocuments)) 3997 if err != nil { 3998 return nil, err 3999 } 4000 return ScanDocumentPersonnes(rows) 4001 } 4002 4003 func DeleteDocumentPersonnesByIdDocuments(tx DB, idDocuments ...int64) (DocumentPersonnes, error) { 4004 rows, err := tx.Query("DELETE FROM document_personnes WHERE id_document = ANY($1) RETURNING *", pq.Int64Array(idDocuments)) 4005 if err != nil { 4006 return nil, err 4007 } 4008 return ScanDocumentPersonnes(rows) 4009 } 4010 4011 func SelectDocumentPersonnesByIdPersonnes(tx DB, idPersonnes ...int64) (DocumentPersonnes, error) { 4012 rows, err := tx.Query("SELECT * FROM document_personnes WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4013 if err != nil { 4014 return nil, err 4015 } 4016 return ScanDocumentPersonnes(rows) 4017 } 4018 4019 func DeleteDocumentPersonnesByIdPersonnes(tx DB, idPersonnes ...int64) (DocumentPersonnes, error) { 4020 rows, err := tx.Query("DELETE FROM document_personnes WHERE id_personne = ANY($1) RETURNING *", pq.Int64Array(idPersonnes)) 4021 if err != nil { 4022 return nil, err 4023 } 4024 return ScanDocumentPersonnes(rows) 4025 } 4026 4027 func SelectDocumentPersonnesByIdContraintes(tx DB, idContraintes ...int64) (DocumentPersonnes, error) { 4028 rows, err := tx.Query("SELECT * FROM document_personnes WHERE id_contrainte = ANY($1)", pq.Int64Array(idContraintes)) 4029 if err != nil { 4030 return nil, err 4031 } 4032 return ScanDocumentPersonnes(rows) 4033 } 4034 4035 func DeleteDocumentPersonnesByIdContraintes(tx DB, idContraintes ...int64) (DocumentPersonnes, error) { 4036 rows, err := tx.Query("DELETE FROM document_personnes WHERE id_contrainte = ANY($1) RETURNING *", pq.Int64Array(idContraintes)) 4037 if err != nil { 4038 return nil, err 4039 } 4040 return ScanDocumentPersonnes(rows) 4041 } 4042 4043 // ByIdDocument returns a map with 'IdDocument' as keys. 4044 func (items DocumentPersonnes) ByIdDocument() map[int64]DocumentPersonne { 4045 out := make(map[int64]DocumentPersonne, len(items)) 4046 for _, target := range items { 4047 out[target.IdDocument] = target 4048 } 4049 return out 4050 } 4051 4052 // ByIdPersonne returns a map with 'IdPersonne' as keys. 4053 func (items DocumentPersonnes) ByIdPersonne() map[int64]DocumentPersonnes { 4054 out := make(map[int64]DocumentPersonnes) 4055 for _, target := range items { 4056 out[target.IdPersonne] = append(out[target.IdPersonne], target) 4057 } 4058 return out 4059 } 4060 4061 // ByIdContrainte returns a map with 'IdContrainte' as keys. 4062 func (items DocumentPersonnes) ByIdContrainte() map[int64]DocumentPersonnes { 4063 out := make(map[int64]DocumentPersonnes) 4064 for _, target := range items { 4065 out[target.IdContrainte] = append(out[target.IdContrainte], target) 4066 } 4067 return out 4068 } 4069 4070 // SelectDonDonateurByIdDon return zero or one item, thanks to a UNIQUE constraint 4071 func SelectDonDonateurByIdDon(tx DB, idDon int64) (item DonDonateur, found bool, err error) { 4072 row := tx.QueryRow("SELECT * FROM don_donateurs WHERE id_don = $1", idDon) 4073 item, err = ScanDonDonateur(row) 4074 if err == sql.ErrNoRows { 4075 return item, false, nil 4076 } 4077 return item, true, err 4078 } 4079 4080 func SelectDonDonateursByIdDons(tx DB, idDons ...int64) (DonDonateurs, error) { 4081 rows, err := tx.Query("SELECT * FROM don_donateurs WHERE id_don = ANY($1)", pq.Int64Array(idDons)) 4082 if err != nil { 4083 return nil, err 4084 } 4085 return ScanDonDonateurs(rows) 4086 } 4087 4088 func DeleteDonDonateursByIdDons(tx DB, idDons ...int64) (DonDonateurs, error) { 4089 rows, err := tx.Query("DELETE FROM don_donateurs WHERE id_don = ANY($1) RETURNING *", pq.Int64Array(idDons)) 4090 if err != nil { 4091 return nil, err 4092 } 4093 return ScanDonDonateurs(rows) 4094 } 4095 4096 func SelectDonDonateursByIdPersonnes(tx DB, idPersonnes ...int64) (DonDonateurs, error) { 4097 rows, err := tx.Query("SELECT * FROM don_donateurs WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4098 if err != nil { 4099 return nil, err 4100 } 4101 return ScanDonDonateurs(rows) 4102 } 4103 4104 func DeleteDonDonateursByIdPersonnes(tx DB, idPersonnes ...int64) (DonDonateurs, error) { 4105 rows, err := tx.Query("DELETE FROM don_donateurs WHERE id_personne = ANY($1) RETURNING *", pq.Int64Array(idPersonnes)) 4106 if err != nil { 4107 return nil, err 4108 } 4109 return ScanDonDonateurs(rows) 4110 } 4111 4112 func SelectDonDonateursByIdOrganismes(tx DB, idOrganismes ...int64) (DonDonateurs, error) { 4113 rows, err := tx.Query("SELECT * FROM don_donateurs WHERE id_organisme = ANY($1)", pq.Int64Array(idOrganismes)) 4114 if err != nil { 4115 return nil, err 4116 } 4117 return ScanDonDonateurs(rows) 4118 } 4119 4120 func DeleteDonDonateursByIdOrganismes(tx DB, idOrganismes ...int64) (DonDonateurs, error) { 4121 rows, err := tx.Query("DELETE FROM don_donateurs WHERE id_organisme = ANY($1) RETURNING *", pq.Int64Array(idOrganismes)) 4122 if err != nil { 4123 return nil, err 4124 } 4125 return ScanDonDonateurs(rows) 4126 } 4127 4128 // ByIdDon returns a map with 'IdDon' as keys. 4129 func (items DonDonateurs) ByIdDon() map[int64]DonDonateur { 4130 out := make(map[int64]DonDonateur, len(items)) 4131 for _, target := range items { 4132 out[target.IdDon] = target 4133 } 4134 return out 4135 } 4136 4137 func SelectEquipiersByIdCamps(tx DB, idCamps ...int64) (Equipiers, error) { 4138 rows, err := tx.Query("SELECT * FROM equipiers WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4139 if err != nil { 4140 return nil, err 4141 } 4142 return ScanEquipiers(rows) 4143 } 4144 4145 func DeleteEquipiersByIdCamps(tx DB, idCamps ...int64) (Ids, error) { 4146 rows, err := tx.Query("DELETE FROM equipiers WHERE id_camp = ANY($1) RETURNING id", pq.Int64Array(idCamps)) 4147 if err != nil { 4148 return nil, err 4149 } 4150 return ScanIds(rows) 4151 } 4152 4153 func SelectEquipiersByIdPersonnes(tx DB, idPersonnes ...int64) (Equipiers, error) { 4154 rows, err := tx.Query("SELECT * FROM equipiers WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4155 if err != nil { 4156 return nil, err 4157 } 4158 return ScanEquipiers(rows) 4159 } 4160 4161 func DeleteEquipiersByIdPersonnes(tx DB, idPersonnes ...int64) (Ids, error) { 4162 rows, err := tx.Query("DELETE FROM equipiers WHERE id_personne = ANY($1) RETURNING id", pq.Int64Array(idPersonnes)) 4163 if err != nil { 4164 return nil, err 4165 } 4166 return ScanIds(rows) 4167 } 4168 4169 func SelectEquipierContraintesByIdEquipiers(tx DB, idEquipiers ...int64) (EquipierContraintes, error) { 4170 rows, err := tx.Query("SELECT * FROM equipier_contraintes WHERE id_equipier = ANY($1)", pq.Int64Array(idEquipiers)) 4171 if err != nil { 4172 return nil, err 4173 } 4174 return ScanEquipierContraintes(rows) 4175 } 4176 4177 func DeleteEquipierContraintesByIdEquipiers(tx DB, idEquipiers ...int64) (EquipierContraintes, error) { 4178 rows, err := tx.Query("DELETE FROM equipier_contraintes WHERE id_equipier = ANY($1) RETURNING *", pq.Int64Array(idEquipiers)) 4179 if err != nil { 4180 return nil, err 4181 } 4182 return ScanEquipierContraintes(rows) 4183 } 4184 4185 func SelectEquipierContraintesByIdContraintes(tx DB, idContraintes ...int64) (EquipierContraintes, error) { 4186 rows, err := tx.Query("SELECT * FROM equipier_contraintes WHERE id_contrainte = ANY($1)", pq.Int64Array(idContraintes)) 4187 if err != nil { 4188 return nil, err 4189 } 4190 return ScanEquipierContraintes(rows) 4191 } 4192 4193 func DeleteEquipierContraintesByIdContraintes(tx DB, idContraintes ...int64) (EquipierContraintes, error) { 4194 rows, err := tx.Query("DELETE FROM equipier_contraintes WHERE id_contrainte = ANY($1) RETURNING *", pq.Int64Array(idContraintes)) 4195 if err != nil { 4196 return nil, err 4197 } 4198 return ScanEquipierContraintes(rows) 4199 } 4200 4201 // ByIdEquipier returns a map with 'IdEquipier' as keys. 4202 func (items EquipierContraintes) ByIdEquipier() map[int64]EquipierContraintes { 4203 out := make(map[int64]EquipierContraintes) 4204 for _, target := range items { 4205 out[target.IdEquipier] = append(out[target.IdEquipier], target) 4206 } 4207 return out 4208 } 4209 4210 // ByIdContrainte returns a map with 'IdContrainte' as keys. 4211 func (items EquipierContraintes) ByIdContrainte() map[int64]EquipierContraintes { 4212 out := make(map[int64]EquipierContraintes) 4213 for _, target := range items { 4214 out[target.IdContrainte] = append(out[target.IdContrainte], target) 4215 } 4216 return out 4217 } 4218 4219 func SelectFacturesByIdPersonnes(tx DB, idPersonnes ...int64) (Factures, error) { 4220 rows, err := tx.Query("SELECT * FROM factures WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4221 if err != nil { 4222 return nil, err 4223 } 4224 return ScanFactures(rows) 4225 } 4226 4227 func DeleteFacturesByIdPersonnes(tx DB, idPersonnes ...int64) (Ids, error) { 4228 rows, err := tx.Query("DELETE FROM factures WHERE id_personne = ANY($1) RETURNING id", pq.Int64Array(idPersonnes)) 4229 if err != nil { 4230 return nil, err 4231 } 4232 return ScanIds(rows) 4233 } 4234 4235 func SelectGroupesByIdCamps(tx DB, idCamps ...int64) (Groupes, error) { 4236 rows, err := tx.Query("SELECT * FROM groupes WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4237 if err != nil { 4238 return nil, err 4239 } 4240 return ScanGroupes(rows) 4241 } 4242 4243 func DeleteGroupesByIdCamps(tx DB, idCamps ...int64) (Ids, error) { 4244 rows, err := tx.Query("DELETE FROM groupes WHERE id_camp = ANY($1) RETURNING id", pq.Int64Array(idCamps)) 4245 if err != nil { 4246 return nil, err 4247 } 4248 return ScanIds(rows) 4249 } 4250 4251 func SelectGroupeContraintesByIdGroupes(tx DB, idGroupes ...int64) (GroupeContraintes, error) { 4252 rows, err := tx.Query("SELECT * FROM groupe_contraintes WHERE id_groupe = ANY($1)", pq.Int64Array(idGroupes)) 4253 if err != nil { 4254 return nil, err 4255 } 4256 return ScanGroupeContraintes(rows) 4257 } 4258 4259 func DeleteGroupeContraintesByIdGroupes(tx DB, idGroupes ...int64) (GroupeContraintes, error) { 4260 rows, err := tx.Query("DELETE FROM groupe_contraintes WHERE id_groupe = ANY($1) RETURNING *", pq.Int64Array(idGroupes)) 4261 if err != nil { 4262 return nil, err 4263 } 4264 return ScanGroupeContraintes(rows) 4265 } 4266 4267 func SelectGroupeContraintesByIdContraintes(tx DB, idContraintes ...int64) (GroupeContraintes, error) { 4268 rows, err := tx.Query("SELECT * FROM groupe_contraintes WHERE id_contrainte = ANY($1)", pq.Int64Array(idContraintes)) 4269 if err != nil { 4270 return nil, err 4271 } 4272 return ScanGroupeContraintes(rows) 4273 } 4274 4275 func DeleteGroupeContraintesByIdContraintes(tx DB, idContraintes ...int64) (GroupeContraintes, error) { 4276 rows, err := tx.Query("DELETE FROM groupe_contraintes WHERE id_contrainte = ANY($1) RETURNING *", pq.Int64Array(idContraintes)) 4277 if err != nil { 4278 return nil, err 4279 } 4280 return ScanGroupeContraintes(rows) 4281 } 4282 4283 // ByIdGroupe returns a map with 'IdGroupe' as keys. 4284 func (items GroupeContraintes) ByIdGroupe() map[int64]GroupeContraintes { 4285 out := make(map[int64]GroupeContraintes) 4286 for _, target := range items { 4287 out[target.IdGroupe] = append(out[target.IdGroupe], target) 4288 } 4289 return out 4290 } 4291 4292 // ByIdContrainte returns a map with 'IdContrainte' as keys. 4293 func (items GroupeContraintes) ByIdContrainte() map[int64]GroupeContraintes { 4294 out := make(map[int64]GroupeContraintes) 4295 for _, target := range items { 4296 out[target.IdContrainte] = append(out[target.IdContrainte], target) 4297 } 4298 return out 4299 } 4300 4301 func SelectGroupeEquipiersByIdGroupes(tx DB, idGroupes ...int64) (GroupeEquipiers, error) { 4302 rows, err := tx.Query("SELECT * FROM groupe_equipiers WHERE id_groupe = ANY($1)", pq.Int64Array(idGroupes)) 4303 if err != nil { 4304 return nil, err 4305 } 4306 return ScanGroupeEquipiers(rows) 4307 } 4308 4309 func DeleteGroupeEquipiersByIdGroupes(tx DB, idGroupes ...int64) (GroupeEquipiers, error) { 4310 rows, err := tx.Query("DELETE FROM groupe_equipiers WHERE id_groupe = ANY($1) RETURNING *", pq.Int64Array(idGroupes)) 4311 if err != nil { 4312 return nil, err 4313 } 4314 return ScanGroupeEquipiers(rows) 4315 } 4316 4317 func SelectGroupeEquipiersByIdEquipiers(tx DB, idEquipiers ...int64) (GroupeEquipiers, error) { 4318 rows, err := tx.Query("SELECT * FROM groupe_equipiers WHERE id_equipier = ANY($1)", pq.Int64Array(idEquipiers)) 4319 if err != nil { 4320 return nil, err 4321 } 4322 return ScanGroupeEquipiers(rows) 4323 } 4324 4325 func DeleteGroupeEquipiersByIdEquipiers(tx DB, idEquipiers ...int64) (GroupeEquipiers, error) { 4326 rows, err := tx.Query("DELETE FROM groupe_equipiers WHERE id_equipier = ANY($1) RETURNING *", pq.Int64Array(idEquipiers)) 4327 if err != nil { 4328 return nil, err 4329 } 4330 return ScanGroupeEquipiers(rows) 4331 } 4332 4333 func SelectGroupeEquipiersByIdCamps(tx DB, idCamps ...int64) (GroupeEquipiers, error) { 4334 rows, err := tx.Query("SELECT * FROM groupe_equipiers WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4335 if err != nil { 4336 return nil, err 4337 } 4338 return ScanGroupeEquipiers(rows) 4339 } 4340 4341 func DeleteGroupeEquipiersByIdCamps(tx DB, idCamps ...int64) (GroupeEquipiers, error) { 4342 rows, err := tx.Query("DELETE FROM groupe_equipiers WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4343 if err != nil { 4344 return nil, err 4345 } 4346 return ScanGroupeEquipiers(rows) 4347 } 4348 4349 // ByIdGroupe returns a map with 'IdGroupe' as keys. 4350 func (items GroupeEquipiers) ByIdGroupe() map[int64]GroupeEquipiers { 4351 out := make(map[int64]GroupeEquipiers) 4352 for _, target := range items { 4353 out[target.IdGroupe] = append(out[target.IdGroupe], target) 4354 } 4355 return out 4356 } 4357 4358 // ByIdEquipier returns a map with 'IdEquipier' as keys. 4359 func (items GroupeEquipiers) ByIdEquipier() map[int64]GroupeEquipiers { 4360 out := make(map[int64]GroupeEquipiers) 4361 for _, target := range items { 4362 out[target.IdEquipier] = append(out[target.IdEquipier], target) 4363 } 4364 return out 4365 } 4366 4367 // ByIdCamp returns a map with 'IdCamp' as keys. 4368 func (items GroupeEquipiers) ByIdCamp() map[int64]GroupeEquipiers { 4369 out := make(map[int64]GroupeEquipiers) 4370 for _, target := range items { 4371 out[target.IdCamp] = append(out[target.IdCamp], target) 4372 } 4373 return out 4374 } 4375 4376 // SelectGroupeParticipantByIdParticipant return zero or one item, thanks to a UNIQUE constraint 4377 func SelectGroupeParticipantByIdParticipant(tx DB, idParticipant int64) (item GroupeParticipant, found bool, err error) { 4378 row := tx.QueryRow("SELECT * FROM groupe_participants WHERE id_participant = $1", idParticipant) 4379 item, err = ScanGroupeParticipant(row) 4380 if err == sql.ErrNoRows { 4381 return item, false, nil 4382 } 4383 return item, true, err 4384 } 4385 4386 func SelectGroupeParticipantsByIdParticipants(tx DB, idParticipants ...int64) (GroupeParticipants, error) { 4387 rows, err := tx.Query("SELECT * FROM groupe_participants WHERE id_participant = ANY($1)", pq.Int64Array(idParticipants)) 4388 if err != nil { 4389 return nil, err 4390 } 4391 return ScanGroupeParticipants(rows) 4392 } 4393 4394 func DeleteGroupeParticipantsByIdParticipants(tx DB, idParticipants ...int64) (GroupeParticipants, error) { 4395 rows, err := tx.Query("DELETE FROM groupe_participants WHERE id_participant = ANY($1) RETURNING *", pq.Int64Array(idParticipants)) 4396 if err != nil { 4397 return nil, err 4398 } 4399 return ScanGroupeParticipants(rows) 4400 } 4401 4402 func SelectGroupeParticipantsByIdGroupes(tx DB, idGroupes ...int64) (GroupeParticipants, error) { 4403 rows, err := tx.Query("SELECT * FROM groupe_participants WHERE id_groupe = ANY($1)", pq.Int64Array(idGroupes)) 4404 if err != nil { 4405 return nil, err 4406 } 4407 return ScanGroupeParticipants(rows) 4408 } 4409 4410 func DeleteGroupeParticipantsByIdGroupes(tx DB, idGroupes ...int64) (GroupeParticipants, error) { 4411 rows, err := tx.Query("DELETE FROM groupe_participants WHERE id_groupe = ANY($1) RETURNING *", pq.Int64Array(idGroupes)) 4412 if err != nil { 4413 return nil, err 4414 } 4415 return ScanGroupeParticipants(rows) 4416 } 4417 4418 func SelectGroupeParticipantsByIdCamps(tx DB, idCamps ...int64) (GroupeParticipants, error) { 4419 rows, err := tx.Query("SELECT * FROM groupe_participants WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4420 if err != nil { 4421 return nil, err 4422 } 4423 return ScanGroupeParticipants(rows) 4424 } 4425 4426 func DeleteGroupeParticipantsByIdCamps(tx DB, idCamps ...int64) (GroupeParticipants, error) { 4427 rows, err := tx.Query("DELETE FROM groupe_participants WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4428 if err != nil { 4429 return nil, err 4430 } 4431 return ScanGroupeParticipants(rows) 4432 } 4433 4434 // ByIdParticipant returns a map with 'IdParticipant' as keys. 4435 func (items GroupeParticipants) ByIdParticipant() map[int64]GroupeParticipant { 4436 out := make(map[int64]GroupeParticipant, len(items)) 4437 for _, target := range items { 4438 out[target.IdParticipant] = target 4439 } 4440 return out 4441 } 4442 4443 // ByIdGroupe returns a map with 'IdGroupe' as keys. 4444 func (items GroupeParticipants) ByIdGroupe() map[int64]GroupeParticipants { 4445 out := make(map[int64]GroupeParticipants) 4446 for _, target := range items { 4447 out[target.IdGroupe] = append(out[target.IdGroupe], target) 4448 } 4449 return out 4450 } 4451 4452 // ByIdCamp returns a map with 'IdCamp' as keys. 4453 func (items GroupeParticipants) ByIdCamp() map[int64]GroupeParticipants { 4454 out := make(map[int64]GroupeParticipants) 4455 for _, target := range items { 4456 out[target.IdCamp] = append(out[target.IdCamp], target) 4457 } 4458 return out 4459 } 4460 4461 func SelectImageuploadedsByIdCamps(tx DB, idCamps ...int64) (Imageuploadeds, error) { 4462 rows, err := tx.Query("SELECT * FROM imageuploadeds WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4463 if err != nil { 4464 return nil, err 4465 } 4466 return ScanImageuploadeds(rows) 4467 } 4468 4469 func DeleteImageuploadedsByIdCamps(tx DB, idCamps ...int64) (Imageuploadeds, error) { 4470 rows, err := tx.Query("DELETE FROM imageuploadeds WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4471 if err != nil { 4472 return nil, err 4473 } 4474 return ScanImageuploadeds(rows) 4475 } 4476 4477 // ByIdCamp returns a map with 'IdCamp' as keys. 4478 func (items Imageuploadeds) ByIdCamp() map[int64]Imageuploadeds { 4479 out := make(map[int64]Imageuploadeds) 4480 for _, target := range items { 4481 out[target.IdCamp] = append(out[target.IdCamp], target) 4482 } 4483 return out 4484 } 4485 4486 // SelectLettredirecteurByIdCamp return zero or one item, thanks to a UNIQUE constraint 4487 func SelectLettredirecteurByIdCamp(tx DB, idCamp int64) (item Lettredirecteur, found bool, err error) { 4488 row := tx.QueryRow("SELECT * FROM lettredirecteurs WHERE id_camp = $1", idCamp) 4489 item, err = ScanLettredirecteur(row) 4490 if err == sql.ErrNoRows { 4491 return item, false, nil 4492 } 4493 return item, true, err 4494 } 4495 4496 func SelectLettredirecteursByIdCamps(tx DB, idCamps ...int64) (Lettredirecteurs, error) { 4497 rows, err := tx.Query("SELECT * FROM lettredirecteurs WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4498 if err != nil { 4499 return nil, err 4500 } 4501 return ScanLettredirecteurs(rows) 4502 } 4503 4504 func DeleteLettredirecteursByIdCamps(tx DB, idCamps ...int64) (Lettredirecteurs, error) { 4505 rows, err := tx.Query("DELETE FROM lettredirecteurs WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4506 if err != nil { 4507 return nil, err 4508 } 4509 return ScanLettredirecteurs(rows) 4510 } 4511 4512 // ByIdCamp returns a map with 'IdCamp' as keys. 4513 func (items Lettredirecteurs) ByIdCamp() map[int64]Lettredirecteur { 4514 out := make(map[int64]Lettredirecteur, len(items)) 4515 for _, target := range items { 4516 out[target.IdCamp] = target 4517 } 4518 return out 4519 } 4520 4521 func SelectMessagesByIdFactures(tx DB, idFactures ...int64) (Messages, error) { 4522 rows, err := tx.Query("SELECT * FROM messages WHERE id_facture = ANY($1)", pq.Int64Array(idFactures)) 4523 if err != nil { 4524 return nil, err 4525 } 4526 return ScanMessages(rows) 4527 } 4528 4529 func DeleteMessagesByIdFactures(tx DB, idFactures ...int64) (Ids, error) { 4530 rows, err := tx.Query("DELETE FROM messages WHERE id_facture = ANY($1) RETURNING id", pq.Int64Array(idFactures)) 4531 if err != nil { 4532 return nil, err 4533 } 4534 return ScanIds(rows) 4535 } 4536 4537 // SelectMessageAttestationByIdMessage return zero or one item, thanks to a UNIQUE constraint 4538 func SelectMessageAttestationByIdMessage(tx DB, idMessage int64) (item MessageAttestation, found bool, err error) { 4539 row := tx.QueryRow("SELECT * FROM message_attestations WHERE id_message = $1", idMessage) 4540 item, err = ScanMessageAttestation(row) 4541 if err == sql.ErrNoRows { 4542 return item, false, nil 4543 } 4544 return item, true, err 4545 } 4546 4547 func SelectMessageAttestationsByIdMessages(tx DB, idMessages ...int64) (MessageAttestations, error) { 4548 rows, err := tx.Query("SELECT * FROM message_attestations WHERE id_message = ANY($1)", pq.Int64Array(idMessages)) 4549 if err != nil { 4550 return nil, err 4551 } 4552 return ScanMessageAttestations(rows) 4553 } 4554 4555 func DeleteMessageAttestationsByIdMessages(tx DB, idMessages ...int64) (MessageAttestations, error) { 4556 rows, err := tx.Query("DELETE FROM message_attestations WHERE id_message = ANY($1) RETURNING *", pq.Int64Array(idMessages)) 4557 if err != nil { 4558 return nil, err 4559 } 4560 return ScanMessageAttestations(rows) 4561 } 4562 4563 // ByIdMessage returns a map with 'IdMessage' as keys. 4564 func (items MessageAttestations) ByIdMessage() map[int64]MessageAttestation { 4565 out := make(map[int64]MessageAttestation, len(items)) 4566 for _, target := range items { 4567 out[target.IdMessage] = target 4568 } 4569 return out 4570 } 4571 4572 // SelectMessageDocumentByIdMessage return zero or one item, thanks to a UNIQUE constraint 4573 func SelectMessageDocumentByIdMessage(tx DB, idMessage int64) (item MessageDocument, found bool, err error) { 4574 row := tx.QueryRow("SELECT * FROM message_documents WHERE id_message = $1", idMessage) 4575 item, err = ScanMessageDocument(row) 4576 if err == sql.ErrNoRows { 4577 return item, false, nil 4578 } 4579 return item, true, err 4580 } 4581 4582 func SelectMessageDocumentsByIdMessages(tx DB, idMessages ...int64) (MessageDocuments, error) { 4583 rows, err := tx.Query("SELECT * FROM message_documents WHERE id_message = ANY($1)", pq.Int64Array(idMessages)) 4584 if err != nil { 4585 return nil, err 4586 } 4587 return ScanMessageDocuments(rows) 4588 } 4589 4590 func DeleteMessageDocumentsByIdMessages(tx DB, idMessages ...int64) (MessageDocuments, error) { 4591 rows, err := tx.Query("DELETE FROM message_documents WHERE id_message = ANY($1) RETURNING *", pq.Int64Array(idMessages)) 4592 if err != nil { 4593 return nil, err 4594 } 4595 return ScanMessageDocuments(rows) 4596 } 4597 4598 func SelectMessageDocumentsByIdCamps(tx DB, idCamps ...int64) (MessageDocuments, error) { 4599 rows, err := tx.Query("SELECT * FROM message_documents WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4600 if err != nil { 4601 return nil, err 4602 } 4603 return ScanMessageDocuments(rows) 4604 } 4605 4606 func DeleteMessageDocumentsByIdCamps(tx DB, idCamps ...int64) (MessageDocuments, error) { 4607 rows, err := tx.Query("DELETE FROM message_documents WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4608 if err != nil { 4609 return nil, err 4610 } 4611 return ScanMessageDocuments(rows) 4612 } 4613 4614 // ByIdMessage returns a map with 'IdMessage' as keys. 4615 func (items MessageDocuments) ByIdMessage() map[int64]MessageDocument { 4616 out := make(map[int64]MessageDocument, len(items)) 4617 for _, target := range items { 4618 out[target.IdMessage] = target 4619 } 4620 return out 4621 } 4622 4623 // ByIdCamp returns a map with 'IdCamp' as keys. 4624 func (items MessageDocuments) ByIdCamp() map[int64]MessageDocuments { 4625 out := make(map[int64]MessageDocuments) 4626 for _, target := range items { 4627 out[target.IdCamp] = append(out[target.IdCamp], target) 4628 } 4629 return out 4630 } 4631 4632 // SelectMessageMessageByIdMessage return zero or one item, thanks to a UNIQUE constraint 4633 func SelectMessageMessageByIdMessage(tx DB, idMessage int64) (item MessageMessage, found bool, err error) { 4634 row := tx.QueryRow("SELECT * FROM message_messages WHERE id_message = $1", idMessage) 4635 item, err = ScanMessageMessage(row) 4636 if err == sql.ErrNoRows { 4637 return item, false, nil 4638 } 4639 return item, true, err 4640 } 4641 4642 func SelectMessageMessagesByIdMessages(tx DB, idMessages ...int64) (MessageMessages, error) { 4643 rows, err := tx.Query("SELECT * FROM message_messages WHERE id_message = ANY($1)", pq.Int64Array(idMessages)) 4644 if err != nil { 4645 return nil, err 4646 } 4647 return ScanMessageMessages(rows) 4648 } 4649 4650 func DeleteMessageMessagesByIdMessages(tx DB, idMessages ...int64) (MessageMessages, error) { 4651 rows, err := tx.Query("DELETE FROM message_messages WHERE id_message = ANY($1) RETURNING *", pq.Int64Array(idMessages)) 4652 if err != nil { 4653 return nil, err 4654 } 4655 return ScanMessageMessages(rows) 4656 } 4657 4658 // ByIdMessage returns a map with 'IdMessage' as keys. 4659 func (items MessageMessages) ByIdMessage() map[int64]MessageMessage { 4660 out := make(map[int64]MessageMessage, len(items)) 4661 for _, target := range items { 4662 out[target.IdMessage] = target 4663 } 4664 return out 4665 } 4666 4667 // SelectMessagePlacelibereByIdMessage return zero or one item, thanks to a UNIQUE constraint 4668 func SelectMessagePlacelibereByIdMessage(tx DB, idMessage int64) (item MessagePlacelibere, found bool, err error) { 4669 row := tx.QueryRow("SELECT * FROM message_placeliberes WHERE id_message = $1", idMessage) 4670 item, err = ScanMessagePlacelibere(row) 4671 if err == sql.ErrNoRows { 4672 return item, false, nil 4673 } 4674 return item, true, err 4675 } 4676 4677 func SelectMessagePlaceliberesByIdMessages(tx DB, idMessages ...int64) (MessagePlaceliberes, error) { 4678 rows, err := tx.Query("SELECT * FROM message_placeliberes WHERE id_message = ANY($1)", pq.Int64Array(idMessages)) 4679 if err != nil { 4680 return nil, err 4681 } 4682 return ScanMessagePlaceliberes(rows) 4683 } 4684 4685 func DeleteMessagePlaceliberesByIdMessages(tx DB, idMessages ...int64) (MessagePlaceliberes, error) { 4686 rows, err := tx.Query("DELETE FROM message_placeliberes WHERE id_message = ANY($1) RETURNING *", pq.Int64Array(idMessages)) 4687 if err != nil { 4688 return nil, err 4689 } 4690 return ScanMessagePlaceliberes(rows) 4691 } 4692 4693 func SelectMessagePlaceliberesByIdParticipants(tx DB, idParticipants ...int64) (MessagePlaceliberes, error) { 4694 rows, err := tx.Query("SELECT * FROM message_placeliberes WHERE id_participant = ANY($1)", pq.Int64Array(idParticipants)) 4695 if err != nil { 4696 return nil, err 4697 } 4698 return ScanMessagePlaceliberes(rows) 4699 } 4700 4701 func DeleteMessagePlaceliberesByIdParticipants(tx DB, idParticipants ...int64) (MessagePlaceliberes, error) { 4702 rows, err := tx.Query("DELETE FROM message_placeliberes WHERE id_participant = ANY($1) RETURNING *", pq.Int64Array(idParticipants)) 4703 if err != nil { 4704 return nil, err 4705 } 4706 return ScanMessagePlaceliberes(rows) 4707 } 4708 4709 // ByIdMessage returns a map with 'IdMessage' as keys. 4710 func (items MessagePlaceliberes) ByIdMessage() map[int64]MessagePlacelibere { 4711 out := make(map[int64]MessagePlacelibere, len(items)) 4712 for _, target := range items { 4713 out[target.IdMessage] = target 4714 } 4715 return out 4716 } 4717 4718 // ByIdParticipant returns a map with 'IdParticipant' as keys. 4719 func (items MessagePlaceliberes) ByIdParticipant() map[int64]MessagePlaceliberes { 4720 out := make(map[int64]MessagePlaceliberes) 4721 for _, target := range items { 4722 out[target.IdParticipant] = append(out[target.IdParticipant], target) 4723 } 4724 return out 4725 } 4726 4727 // SelectMessageSondageByIdMessage return zero or one item, thanks to a UNIQUE constraint 4728 func SelectMessageSondageByIdMessage(tx DB, idMessage int64) (item MessageSondage, found bool, err error) { 4729 row := tx.QueryRow("SELECT * FROM message_sondages WHERE id_message = $1", idMessage) 4730 item, err = ScanMessageSondage(row) 4731 if err == sql.ErrNoRows { 4732 return item, false, nil 4733 } 4734 return item, true, err 4735 } 4736 4737 func SelectMessageSondagesByIdMessages(tx DB, idMessages ...int64) (MessageSondages, error) { 4738 rows, err := tx.Query("SELECT * FROM message_sondages WHERE id_message = ANY($1)", pq.Int64Array(idMessages)) 4739 if err != nil { 4740 return nil, err 4741 } 4742 return ScanMessageSondages(rows) 4743 } 4744 4745 func DeleteMessageSondagesByIdMessages(tx DB, idMessages ...int64) (MessageSondages, error) { 4746 rows, err := tx.Query("DELETE FROM message_sondages WHERE id_message = ANY($1) RETURNING *", pq.Int64Array(idMessages)) 4747 if err != nil { 4748 return nil, err 4749 } 4750 return ScanMessageSondages(rows) 4751 } 4752 4753 func SelectMessageSondagesByIdCamps(tx DB, idCamps ...int64) (MessageSondages, error) { 4754 rows, err := tx.Query("SELECT * FROM message_sondages WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4755 if err != nil { 4756 return nil, err 4757 } 4758 return ScanMessageSondages(rows) 4759 } 4760 4761 func DeleteMessageSondagesByIdCamps(tx DB, idCamps ...int64) (MessageSondages, error) { 4762 rows, err := tx.Query("DELETE FROM message_sondages WHERE id_camp = ANY($1) RETURNING *", pq.Int64Array(idCamps)) 4763 if err != nil { 4764 return nil, err 4765 } 4766 return ScanMessageSondages(rows) 4767 } 4768 4769 // ByIdMessage returns a map with 'IdMessage' as keys. 4770 func (items MessageSondages) ByIdMessage() map[int64]MessageSondage { 4771 out := make(map[int64]MessageSondage, len(items)) 4772 for _, target := range items { 4773 out[target.IdMessage] = target 4774 } 4775 return out 4776 } 4777 4778 // ByIdCamp returns a map with 'IdCamp' as keys. 4779 func (items MessageSondages) ByIdCamp() map[int64]MessageSondages { 4780 out := make(map[int64]MessageSondages) 4781 for _, target := range items { 4782 out[target.IdCamp] = append(out[target.IdCamp], target) 4783 } 4784 return out 4785 } 4786 4787 func SelectOrganismesByIdContacts(tx DB, idContacts ...int64) (Organismes, error) { 4788 rows, err := tx.Query("SELECT * FROM organismes WHERE id_contact = ANY($1)", pq.Int64Array(idContacts)) 4789 if err != nil { 4790 return nil, err 4791 } 4792 return ScanOrganismes(rows) 4793 } 4794 4795 func DeleteOrganismesByIdContacts(tx DB, idContacts ...int64) (Ids, error) { 4796 rows, err := tx.Query("DELETE FROM organismes WHERE id_contact = ANY($1) RETURNING id", pq.Int64Array(idContacts)) 4797 if err != nil { 4798 return nil, err 4799 } 4800 return ScanIds(rows) 4801 } 4802 4803 func SelectOrganismesByIdContactDons(tx DB, idContactDons ...int64) (Organismes, error) { 4804 rows, err := tx.Query("SELECT * FROM organismes WHERE id_contact_don = ANY($1)", pq.Int64Array(idContactDons)) 4805 if err != nil { 4806 return nil, err 4807 } 4808 return ScanOrganismes(rows) 4809 } 4810 4811 func DeleteOrganismesByIdContactDons(tx DB, idContactDons ...int64) (Ids, error) { 4812 rows, err := tx.Query("DELETE FROM organismes WHERE id_contact_don = ANY($1) RETURNING id", pq.Int64Array(idContactDons)) 4813 if err != nil { 4814 return nil, err 4815 } 4816 return ScanIds(rows) 4817 } 4818 4819 func SelectPaiementsByIdFactures(tx DB, idFactures ...int64) (Paiements, error) { 4820 rows, err := tx.Query("SELECT * FROM paiements WHERE id_facture = ANY($1)", pq.Int64Array(idFactures)) 4821 if err != nil { 4822 return nil, err 4823 } 4824 return ScanPaiements(rows) 4825 } 4826 4827 func DeletePaiementsByIdFactures(tx DB, idFactures ...int64) (Ids, error) { 4828 rows, err := tx.Query("DELETE FROM paiements WHERE id_facture = ANY($1) RETURNING id", pq.Int64Array(idFactures)) 4829 if err != nil { 4830 return nil, err 4831 } 4832 return ScanIds(rows) 4833 } 4834 4835 func SelectParticipantsByIdCamps(tx DB, idCamps ...int64) (Participants, error) { 4836 rows, err := tx.Query("SELECT * FROM participants WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4837 if err != nil { 4838 return nil, err 4839 } 4840 return ScanParticipants(rows) 4841 } 4842 4843 func DeleteParticipantsByIdCamps(tx DB, idCamps ...int64) (Ids, error) { 4844 rows, err := tx.Query("DELETE FROM participants WHERE id_camp = ANY($1) RETURNING id", pq.Int64Array(idCamps)) 4845 if err != nil { 4846 return nil, err 4847 } 4848 return ScanIds(rows) 4849 } 4850 4851 func SelectParticipantsByIdPersonnes(tx DB, idPersonnes ...int64) (Participants, error) { 4852 rows, err := tx.Query("SELECT * FROM participants WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4853 if err != nil { 4854 return nil, err 4855 } 4856 return ScanParticipants(rows) 4857 } 4858 4859 func DeleteParticipantsByIdPersonnes(tx DB, idPersonnes ...int64) (Ids, error) { 4860 rows, err := tx.Query("DELETE FROM participants WHERE id_personne = ANY($1) RETURNING id", pq.Int64Array(idPersonnes)) 4861 if err != nil { 4862 return nil, err 4863 } 4864 return ScanIds(rows) 4865 } 4866 4867 func SelectParticipantsByIdFactures(tx DB, idFactures ...int64) (Participants, error) { 4868 rows, err := tx.Query("SELECT * FROM participants WHERE id_facture = ANY($1)", pq.Int64Array(idFactures)) 4869 if err != nil { 4870 return nil, err 4871 } 4872 return ScanParticipants(rows) 4873 } 4874 4875 func DeleteParticipantsByIdFactures(tx DB, idFactures ...int64) (Ids, error) { 4876 rows, err := tx.Query("DELETE FROM participants WHERE id_facture = ANY($1) RETURNING id", pq.Int64Array(idFactures)) 4877 if err != nil { 4878 return nil, err 4879 } 4880 return ScanIds(rows) 4881 } 4882 4883 // SelectParticipantEquipierByIdParticipant return zero or one item, thanks to a UNIQUE constraint 4884 func SelectParticipantEquipierByIdParticipant(tx DB, idParticipant int64) (item ParticipantEquipier, found bool, err error) { 4885 row := tx.QueryRow("SELECT * FROM participant_equipiers WHERE id_participant = $1", idParticipant) 4886 item, err = ScanParticipantEquipier(row) 4887 if err == sql.ErrNoRows { 4888 return item, false, nil 4889 } 4890 return item, true, err 4891 } 4892 4893 func SelectParticipantEquipiersByIdParticipants(tx DB, idParticipants ...int64) (ParticipantEquipiers, error) { 4894 rows, err := tx.Query("SELECT * FROM participant_equipiers WHERE id_participant = ANY($1)", pq.Int64Array(idParticipants)) 4895 if err != nil { 4896 return nil, err 4897 } 4898 return ScanParticipantEquipiers(rows) 4899 } 4900 4901 func DeleteParticipantEquipiersByIdParticipants(tx DB, idParticipants ...int64) (ParticipantEquipiers, error) { 4902 rows, err := tx.Query("DELETE FROM participant_equipiers WHERE id_participant = ANY($1) RETURNING *", pq.Int64Array(idParticipants)) 4903 if err != nil { 4904 return nil, err 4905 } 4906 return ScanParticipantEquipiers(rows) 4907 } 4908 4909 func SelectParticipantEquipiersByIdEquipiers(tx DB, idEquipiers ...int64) (ParticipantEquipiers, error) { 4910 rows, err := tx.Query("SELECT * FROM participant_equipiers WHERE id_equipier = ANY($1)", pq.Int64Array(idEquipiers)) 4911 if err != nil { 4912 return nil, err 4913 } 4914 return ScanParticipantEquipiers(rows) 4915 } 4916 4917 func DeleteParticipantEquipiersByIdEquipiers(tx DB, idEquipiers ...int64) (ParticipantEquipiers, error) { 4918 rows, err := tx.Query("DELETE FROM participant_equipiers WHERE id_equipier = ANY($1) RETURNING *", pq.Int64Array(idEquipiers)) 4919 if err != nil { 4920 return nil, err 4921 } 4922 return ScanParticipantEquipiers(rows) 4923 } 4924 4925 func SelectParticipantEquipiersByIdGroupes(tx DB, idGroupes ...int64) (ParticipantEquipiers, error) { 4926 rows, err := tx.Query("SELECT * FROM participant_equipiers WHERE id_groupe = ANY($1)", pq.Int64Array(idGroupes)) 4927 if err != nil { 4928 return nil, err 4929 } 4930 return ScanParticipantEquipiers(rows) 4931 } 4932 4933 func DeleteParticipantEquipiersByIdGroupes(tx DB, idGroupes ...int64) (ParticipantEquipiers, error) { 4934 rows, err := tx.Query("DELETE FROM participant_equipiers WHERE id_groupe = ANY($1) RETURNING *", pq.Int64Array(idGroupes)) 4935 if err != nil { 4936 return nil, err 4937 } 4938 return ScanParticipantEquipiers(rows) 4939 } 4940 4941 // ByIdParticipant returns a map with 'IdParticipant' as keys. 4942 func (items ParticipantEquipiers) ByIdParticipant() map[int64]ParticipantEquipier { 4943 out := make(map[int64]ParticipantEquipier, len(items)) 4944 for _, target := range items { 4945 out[target.IdParticipant] = target 4946 } 4947 return out 4948 } 4949 4950 // ByIdEquipier returns a map with 'IdEquipier' as keys. 4951 func (items ParticipantEquipiers) ByIdEquipier() map[int64]ParticipantEquipiers { 4952 out := make(map[int64]ParticipantEquipiers) 4953 for _, target := range items { 4954 out[target.IdEquipier] = append(out[target.IdEquipier], target) 4955 } 4956 return out 4957 } 4958 4959 // ByIdGroupe returns a map with 'IdGroupe' as keys. 4960 func (items ParticipantEquipiers) ByIdGroupe() map[int64]ParticipantEquipiers { 4961 out := make(map[int64]ParticipantEquipiers) 4962 for _, target := range items { 4963 out[target.IdGroupe] = append(out[target.IdGroupe], target) 4964 } 4965 return out 4966 } 4967 4968 func SelectParticipantsimplesByIdPersonnes(tx DB, idPersonnes ...int64) (Participantsimples, error) { 4969 rows, err := tx.Query("SELECT * FROM participantsimples WHERE id_personne = ANY($1)", pq.Int64Array(idPersonnes)) 4970 if err != nil { 4971 return nil, err 4972 } 4973 return ScanParticipantsimples(rows) 4974 } 4975 4976 func DeleteParticipantsimplesByIdPersonnes(tx DB, idPersonnes ...int64) (Ids, error) { 4977 rows, err := tx.Query("DELETE FROM participantsimples WHERE id_personne = ANY($1) RETURNING id", pq.Int64Array(idPersonnes)) 4978 if err != nil { 4979 return nil, err 4980 } 4981 return ScanIds(rows) 4982 } 4983 4984 func SelectParticipantsimplesByIdCamps(tx DB, idCamps ...int64) (Participantsimples, error) { 4985 rows, err := tx.Query("SELECT * FROM participantsimples WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 4986 if err != nil { 4987 return nil, err 4988 } 4989 return ScanParticipantsimples(rows) 4990 } 4991 4992 func DeleteParticipantsimplesByIdCamps(tx DB, idCamps ...int64) (Ids, error) { 4993 rows, err := tx.Query("DELETE FROM participantsimples WHERE id_camp = ANY($1) RETURNING id", pq.Int64Array(idCamps)) 4994 if err != nil { 4995 return nil, err 4996 } 4997 return ScanIds(rows) 4998 } 4999 5000 func SelectSondagesByIdCamps(tx DB, idCamps ...int64) (Sondages, error) { 5001 rows, err := tx.Query("SELECT * FROM sondages WHERE id_camp = ANY($1)", pq.Int64Array(idCamps)) 5002 if err != nil { 5003 return nil, err 5004 } 5005 return ScanSondages(rows) 5006 } 5007 5008 func DeleteSondagesByIdCamps(tx DB, idCamps ...int64) (Ids, error) { 5009 rows, err := tx.Query("DELETE FROM sondages WHERE id_camp = ANY($1) RETURNING id", pq.Int64Array(idCamps)) 5010 if err != nil { 5011 return nil, err 5012 } 5013 return ScanIds(rows) 5014 } 5015 5016 func SelectSondagesByIdFactures(tx DB, idFactures ...int64) (Sondages, error) { 5017 rows, err := tx.Query("SELECT * FROM sondages WHERE id_facture = ANY($1)", pq.Int64Array(idFactures)) 5018 if err != nil { 5019 return nil, err 5020 } 5021 return ScanSondages(rows) 5022 } 5023 5024 func DeleteSondagesByIdFactures(tx DB, idFactures ...int64) (Ids, error) { 5025 rows, err := tx.Query("DELETE FROM sondages WHERE id_facture = ANY($1) RETURNING id", pq.Int64Array(idFactures)) 5026 if err != nil { 5027 return nil, err 5028 } 5029 return ScanIds(rows) 5030 }