func (db *Bolt) CreateLink(link *models.Link) error {
	err := db.store.Update(func(tx *bolt.Tx) error {
		bucket := tx.Bucket([]byte(storage.LinksBucket))

		exists := bucket.Get([]byte(link.ID))
		if exists != nil {
			return utilErrors.ErrExists
		}

		encodedLink, err := json.Marshal(link)
		if err != nil {
			return err
		}

		err = bucket.Put([]byte(link.ID), encodedLink)
		if err != nil {
			return err
		}

		return nil
	})
	if err != nil {
		return err
	}

	return nil
}
// CreateLink stores a new link into database
CreateLink stores a new link into database
// CreateLink stores a new link into database
func (db *Bolt) CreateLink(link *models.Link) error {
	err := db.store.Update(func(tx *bolt.Tx) error {
		bucket := tx.Bucket([]byte(storage.LinksBucket))
		exists := bucket.Get([]byte(link.ID))
		if exists != nil {
			return utilErrors.ErrExists
		}
		encodedLink, err := json.Marshal(link)
		if err != nil {
			return err
		}
		err = bucket.Put([]byte(link.ID), encodedLink)
		if err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return err
	}
	return nil
}
func ( db * Bolt ) CreateLink ( link * models . Link ) error { err := db . store . Update ( func ( tx * bolt . Tx ) error { bucket := tx . Bucket ( [ ] byte ( storage . LinksBucket ) ) exists := bucket . Get ( [ ] byte ( link . ID ) ) if exists != nil { return utilErrors . ErrExists } encodedLink , err := json . Marshal ( link ) if err != nil { return err } err = bucket . Put ( [ ] byte ( link . ID ) , encodedLink ) if err != nil { return err } return nil } ) if err != nil { return err } return nil }
CreateLink stores a new link into database
CreateLink stores a new link into database