func createNewEntity(url string, entity *Entity) error {
	err := NewEntityDir()
	if err != nil {
		log.Println("Error creating entity dir: ", err)
	}

	go ExtractData(entity, url)

	id, err := uuid.NewV4()
	if err != nil {
		log.Println("Error creating UUID: ", err)
	}

	// Set new entities' initial data from the request.
	entity.Status = ParsingStatus
	entity.Url = url
	entity.UUID = id.String()
	entity.CreatedAt = time.Now()

	// Persist new entity into the database.
	err = Create(entity)
	if err != nil {
		return err
	}

	err = Find(entity, bson.M{"uuid": entity.UUID}).One(&entity)
	if err != nil {
		return err
	}

	return err
}
// Create a new entity to persist into the database - start HTML extraction.
Create a new entity to persist into the database - start HTML extraction.
// Create a new entity to persist into the database - start HTML extraction .
func createNewEntity(url string, entity *Entity) error {
	err := NewEntityDir()
	if err != nil {
		log.Println("Error creating entity dir: ", err)
	}
	go ExtractData(entity, url)
	id, err := uuid.NewV4()
	if err != nil {
		log.Println("Error creating UUID: ", err)
	}
	entity.Status = ParsingStatus
	entity.Url = url
	entity.UUID = id.String()
	entity.CreatedAt = time.Now()
	err = Create(entity)
	if err != nil {
		return err
	}
	err = Find(entity, bson.M{"uuid": entity.UUID}).One(&entity)
	if err != nil {
		return err
	}
	return err
}
func createNewEntity ( url string , entity * Entity ) error { err := NewEntityDir ( ) if err != nil { log . Println ( " " , err ) } go ExtractData ( entity , url ) id , err := uuid . NewV4 ( ) if err != nil { log . Println ( " " , err ) } entity . Status = ParsingStatus entity . Url = url entity . UUID = id . String ( ) entity . CreatedAt = time . Now ( ) err = Create ( entity ) if err != nil { return err } err = Find ( entity , bson . M { " " : entity . UUID } ) . One ( & entity ) if err != nil { return err } return err }
Create a new entity to persist into the database - start HTML extraction.
Create a new entity to persist into the database - start HTML extraction .
// Set new entities' initial data from the request. // Persist new entity into the database.