예제 #1
0
파일: server.go 프로젝트: huskydocs/api
func persistProject(p Project, ps *persistence.PersistenceSession) error {
	owner, err := ps.Subject(p.Subject)
	if err != nil {
		return err
	}

	ownerRef := mgo.DBRef{Collection: "subject", Id: owner.Id}
	project := &persistence.Project{Owner: ownerRef, Name: p.Name, Description: p.Description}
	err = ps.CreateProject(project)
	return err
}
예제 #2
0
파일: server.go 프로젝트: huskydocs/api
func persistDocument(d Document, ps *persistence.PersistenceSession) error {
	owner, err := ps.Subject(d.Subject)
	if err != nil {
		return err
	}

	project, err := ps.Project(&owner, d.Project)
	if err != nil {
		return err
	}
	projectRef := mgo.DBRef{Collection: "project", Id: project.Id}

	document := &persistence.Document{Project: projectRef, Path: d.Path}
	err = ps.CreateDocument(document)
	return err
}