2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package utils
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-12 16:11:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import (
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"cloud.o-forge.io/core/oc-lib/dbs"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"cloud.o-forge.io/core/oc-lib/tools"
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 11:05:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"github.com/rs/zerolog"
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-12 16:11:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-01 09:13:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-30 14:50:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// ShallowDBObject is an interface that defines the basic methods shallowed version of a DBObject
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-23 11:22:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								type ShallowDBObject interface {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GenerateID()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetID() string
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetName() string
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 11:05:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Serialize(obj DBObject) map[string]interface{}
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Deserialize(j map[string]interface{}, obj DBObject) DBObject
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-23 11:22:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-30 14:50:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// DBObject is an interface that defines the basic methods for a DBObject
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type DBObject interface {
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-19 10:54:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GenerateID()
							 | 
						
					
						
							
								
									
										
										
										
											2025-06-24 11:29:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									SetID(id string)
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-19 13:27:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetID() string
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetName() string
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-12 16:25:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									IsDrafted() bool
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									CanDelete() bool
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									StoreDraftDefault()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetCreatorID() string
							 | 
						
					
						
							
								
									
										
										
										
											2025-02-03 11:52:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									UpToDate(user string, peer string, create bool)
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									CanUpdate(set DBObject) (bool, DBObject)
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-12 16:25:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									VerifyAuth(request *tools.APIRequest) bool
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 11:05:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Serialize(obj DBObject) map[string]interface{}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-12 16:25:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetAccessor(request *tools.APIRequest) Accessor
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Deserialize(j map[string]interface{}, obj DBObject) DBObject
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-30 14:50:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Accessor is an interface that defines the basic methods for an Accessor
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type Accessor interface {
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-04 11:33:08 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetUser() string
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 11:05:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetPeerID() string
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetGroups() []string
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ShouldVerifyAuth() bool
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									GetType() tools.DataType
							 | 
						
					
						
							
								
									
										
										
										
											2024-11-28 11:05:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetLogger() *zerolog.Logger
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-12 16:11:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetCaller() *tools.HTTPCaller
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									GetRequest() *tools.APIRequest
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-19 11:27:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									LoadOne(id string) (DBObject, int, error)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DeleteOne(id string) (DBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-19 13:41:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									CopyOne(data DBObject) (DBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-19 11:27:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									StoreOne(data DBObject) (DBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									LoadAll(isDraft bool) ([]ShallowDBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-22 16:12:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									UpdateOne(set DBObject, id string) (DBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-21 16:50:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Search(filters *dbs.Filters, search string, isDraft bool) ([]ShallowDBObject, int, error)
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-18 11:51:12 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |