changes: - Only one storage endpoint can be defined. This consists of a URL which can be used to specify whether the data is to be stored in a file or in a database.
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package db
 | |
| 
 | |
| import (
 | |
| 	"github.com/Masterminds/semver"
 | |
| 	"github.com/spf13/cobra"
 | |
| )
 | |
| 
 | |
| var (
 | |
| 	configFile *string
 | |
| 
 | |
| 	version *semver.Version
 | |
| )
 | |
| 
 | |
| var dbCmd = &cobra.Command{
 | |
| 	Use:   "db",
 | |
| 	Short: "Operates with the configured database",
 | |
| 	Run: func(cmd *cobra.Command, args []string) {
 | |
| 
 | |
| 		// // read configuration
 | |
| 		// cnf, err := config.Read(*configFile)
 | |
| 		// if err != nil {
 | |
| 		// 	log.Fatalln(err)
 | |
| 		// }
 | |
| 
 | |
| 		// postgresDB, err := database.New(cnf.DatabaseSettings)
 | |
| 		// if err != nil {
 | |
| 		// 	log.Fatalf("%v", err)
 | |
| 		// }
 | |
| 
 | |
| 		// ctx := context.Background()
 | |
| 
 | |
| 		// devices := []*types.Device{
 | |
| 		// 	&types.Device{
 | |
| 		// 		DeviceID:   "1684df26-bc72-4435-a4f9-74b24bdb286c",
 | |
| 		// 		DeviceName: "raspberr-pi",
 | |
| 		// 	},
 | |
| 		// 	&types.Device{
 | |
| 		// 		DeviceID:   "1684df26-bc72-4435-a4f9-74b24bdb286c",
 | |
| 		// 		DeviceName: "raspberr-pi",
 | |
| 		// 	},
 | |
| 		// }
 | |
| 
 | |
| 		// if err := postgresDB.InsertDevices(ctx, devices); err != nil {
 | |
| 		// 	log.Fatalln(err)
 | |
| 		// }
 | |
| 	},
 | |
| }
 | |
| 
 | |
| // Execute a
 | |
| func InitCmd(cmd *cobra.Command, cnfFile *string, sversion *semver.Version) {
 | |
| 	configFile = cnfFile
 | |
| 	version = sversion
 | |
| 
 | |
| 	cmd.AddCommand(dbCmd)
 | |
| 
 | |
| }
 |