Documentation
¶
Index ¶
- func AddItem(userID uuid.UUID, args map[string]interface{}) (addedItem *models.Item, err error)
- func AddItemsToStore(userID uuid.UUID, args map[string]interface{}) (addedItems []*models.Item, err error)
- func AddStapleItemsToNewTrip(trip models.GroceryTrip) (err error)
- func CompileItemSettingsMap(itemSettings datatypes.JSON) (settings map[string]interface{}, err error)
- func CopyRemainingItemsToNewTrip(trip models.GroceryTrip, newTrip *models.GroceryTrip, tx *gorm.DB) (err error)
- func DeleteItem(itemID interface{}) (deletedItem models.Item, err error)
- func FindDefaultStore(userID uuid.UUID) (store models.Store, err error)
- func FindOrCreateStore(userID uuid.UUID, name string) (storeRecord models.Store, err error)
- func GetNewPosition(tripID uuid.UUID, completed bool) int
- func MarkItemAsCompleted(name string, userID uuid.UUID) (updatedItems []*models.Item, err error)
- func MarkItemsInOldTripAsCompleted(trip models.GroceryTrip, tx *gorm.DB) (err error)
- func ReorderItem(itemID interface{}, position int) (*models.GroceryTrip, error)
- func RetrieveCurrentStoreTrip(storeID uuid.UUID) (groceryTrip models.GroceryTrip, err error)
- func RetrieveCurrentStoreTripForUser(storeID uuid.UUID, user models.User) (groceryTrip models.GroceryTrip, err error)
- func RetrieveItems(tripID uuid.UUID) (interface{}, error)
- func RetrieveItemsInCategory(tripID uuid.UUID, categoryID uuid.UUID) (interface{}, error)
- func RetrieveTrip(tripID interface{}) (models.GroceryTrip, error)
- func RetrieveTrips(storeID interface{}, userID uuid.UUID, completed bool) (tripsList []models.GroceryTrip, err error)
- func SaveStoreCategorySelection(item *models.Item, storeCategoryID uuid.UUID) (err error)
- func SearchForItemByName(name string, userID uuid.UUID) (item *models.Item, err error)
- func UpdateItem(args map[string]interface{}) (interface{}, error)
- func UpdateStoreItemCategorySettings(itemName string, storeCategoryID uuid.UUID, ...) (err error)
- func UpdateTrip(args map[string]interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddItemsToStore ¶
func AddItemsToStore(userID uuid.UUID, args map[string]interface{}) (addedItems []*models.Item, err error)
AddItemsToStore adds an array of items to a store for a user. It creates the store for the user if it doesn't already exist.
func AddStapleItemsToNewTrip ¶
func AddStapleItemsToNewTrip(trip models.GroceryTrip) (err error)
AddStapleItemsToNewTrip adds items set as staple items for this store to the new trip
func CompileItemSettingsMap ¶
func CompileItemSettingsMap(itemSettings datatypes.JSON) (settings map[string]interface{}, err error)
CompileItemSettingsMap unmarshals the existing item settings json map, or makes a new map if one does not exist yet
func CopyRemainingItemsToNewTrip ¶
func CopyRemainingItemsToNewTrip( trip models.GroceryTrip, newTrip *models.GroceryTrip, tx *gorm.DB, ) (err error)
func DeleteItem ¶
DeleteItem deletes an item from a trip and handles trip category cleanup (i.e. if this is the last item in a trip category, it deletes the trip category)
func FindDefaultStore ¶
FindDefaultStore retrieves the ID of the store that is set as the default for the userID provided
func FindOrCreateStore ¶
FindOrCreateStore finds or creates a store for a userID by name
func GetNewPosition ¶
GetNewPosition gets the new position of an updated item
func MarkItemAsCompleted ¶
MarkItemAsCompleted item as completed by name for user (in any store)
func MarkItemsInOldTripAsCompleted ¶
func MarkItemsInOldTripAsCompleted(trip models.GroceryTrip, tx *gorm.DB) (err error)
MarkItemsInOldTripAsCompleted marks each item in the old trip as completed
This uses UpdateColumn to avoid hooks (https://gorm.io/docs/update.html#Without-Hooks-Time-Tracking)
func ReorderItem ¶
func ReorderItem(itemID interface{}, position int) (*models.GroceryTrip, error)
ReorderItem handles the reordering of an item by taking the item ID and the new position. It returns the reordered trip object.
func RetrieveCurrentStoreTrip ¶
func RetrieveCurrentStoreTrip(storeID uuid.UUID) (groceryTrip models.GroceryTrip, err error)
RetrieveCurrentStoreTrip retrieves the currently active grocery trip in a store
func RetrieveCurrentStoreTripForUser ¶
func RetrieveCurrentStoreTripForUser(storeID uuid.UUID, user models.User) (groceryTrip models.GroceryTrip, err error)
RetrieveCurrentStoreTripForUser retrieves the currently active grocery trip in a store by storeID if the userID has access to to the store
func RetrieveItems ¶
RetrieveItems finds all items in a grocery trip by tripID
func RetrieveItemsInCategory ¶
RetrieveItemsInCategory finds all items in a grocery trip by category
func RetrieveTrip ¶
func RetrieveTrip(tripID interface{}) (models.GroceryTrip, error)
RetrieveTrip retrieves a specific grocery trip by ID
func RetrieveTrips ¶
func RetrieveTrips(storeID interface{}, userID uuid.UUID, completed bool) (tripsList []models.GroceryTrip, err error)
RetrieveTrips retrieves grocery trips within a store
func SaveStoreCategorySelection ¶
SaveStoreCategorySelection updates the store item category settings for a given item in a store, so that the item will be added to this category going forwards
func SearchForItemByName ¶
SearchForItemByName finds an item within the stores the user belongs to
func UpdateItem ¶
UpdateItem updates an item by itemID
func UpdateStoreItemCategorySettings ¶
func UpdateStoreItemCategorySettings( itemName string, storeCategoryID uuid.UUID, storeItemCategorySetting models.StoreItemCategorySettings, ) (err error)
UpdateStoreItemCategorySettings unpacks the item settings, adds/updates the key by item name, repacks the updated item settings into JSON, and saves it
func UpdateTrip ¶
UpdateTrip updates a grocery trip with the given args by tripID
Types ¶
This section is empty.