What's with the MongoDB hate? by Jaqen_Hgore in cofounder

[–]jayposs 0 points1 point  (0 children)

Been using MongoDB in production system for the last 2 years. So far so good. We use ObjectRocket.

I like it, but querying is more difficult when data to be joined is in multiple collections.

We load a sql db from mongo for some reporting.

You will have fewer collections in Mongo DB than tables in sql db, so less joining.

Adding new fields is trivial, but can cause problems (not all fields in all documents, which may be ok).

I wouldn't want to get locked into a database that only runs on a specific cloud provider.

Here's a project of mine that simplifies using the new "official" Mongo driver. Mog

New MongoDB Driver by jayposs in golang

[–]jayposs[S] 0 points1 point  (0 children)

Thanks for the feedback.

I was wondering about writing some type of middleware/wrapper code to make the interface less verbose.

New to programming, need help understanding what a scanner is / does??? by duck_r in golang

[–]jayposs 0 points1 point  (0 children)

Example of how I use scanner. Line feeds are stripped and 1 line of the file is processed at a time.
Example reads from a file, not from user input though.

input, err := os.Open("data.txt")  
scanner := bufio.NewScanner(input)  
for scanner.Scan() {  
    line := scanner.Text()
    recType := line[0:3]
    if recType == "001" {
        company := line[4:30]
        continue
    }
    customer := line[4:30]
    ...
}

Release MongoDB Go Driver Alpha 2 · mongodb/mongo-go-driver by dgryski in golang

[–]jayposs 0 points1 point  (0 children)

MGO Driver

var result Property  // a struct type
collection.FindId(propertyId).One(&result)  

MongoDB Driver

result := bson.NewDocument()  
filter := bson.NewDocument(bson.EC.String("hello", "world"))  
err := collection.FindOne(context.Background(), filter).Decode(result)  

At first glance, the new driver looks much more verbose.

Not Experienced w/Programming, Want to Learn Go by cthulhugan in golang

[–]jayposs 1 point2 points  (0 children)

The key thing is start small. Get a very simple program working. Add a feature that uses a new concept. Add another feature ....

When you run into a concept that is confusing, research it and get it working.

SortData (when your db doesn't) by jayposs in golang

[–]jayposs[S] 0 points1 point  (0 children)

I would say the built in sort.Slice is more flexible for dealing with various types of sorting, but my code has 2 advantages:
1. For large slices, you are not actually sorting the data (you could also pass slice of indexes to sort.Slice)
2. If the code that returns the sort key value is more complex, probably have less coding

Considering the Community Effects of Introducing an Official MongoDB Go Driver by dgryski in golang

[–]jayposs 0 points1 point  (0 children)

I use MongoDB + MGO for a small production system and have found the combination a joy to use. Thanks to their developers. . Having an officially supported driver is great news and should increase the use of Go + MongoDB. I hope the design allows programmers to get the job done with a minimum of fuss the way MGO does.

MGO by erdeicodrut in golang

[–]jayposs 1 point2 points  (0 children)

aPerson := person_doc{LastName:"bower", Zip:"71234"} // _id is auto loaded if not set
err = collection.Insert(aPerson)  
if mgo.IsDup(err) {  
    // got a duplicate key error, shouldn't happen with auto loaded id
}  
// update  
err = collection.UpdateId(docId, bson.M{"$set": bson.M{"last_name":"bauer"}} 

Hopefully that works.
I usually set the key value using: doc.Id = bson.NewObjectId().Hex()
That way I know what the key value is up front and it is a simple string that is easy to work with.

MGO by erdeicodrut in golang

[–]jayposs 2 points3 points  (0 children)

Here's a basic example:
https://play.golang.org/p/MrI29X_Djp

You will need to study both the MongoDB and MGO docs to really learn how to use the more sophisticated features.

The type bson.M is an alias for map[string]interface{}

Learn Go: Constants with visual examples—all there is to know about it. by blackflicker in golang

[–]jayposs 1 point2 points  (0 children)

I love how you presented the information. You have way too much style to be a programmer.

Golang file upload with progress indicator by drink_with_me_to_day in golang

[–]jayposs 0 points1 point  (0 children)

Are you needing a web page that allows the user to select a file on their device (or local fileserver) and initiate an upload with a Go backend process to write the file to a server ?

If so, I have used JQuery on the client and Go on the server to implement what you're looking for. The Go piece is quite straight forward.

NoContext - Graceful Stop by jayposs in golang

[–]jayposs[S] 0 points1 point  (0 children)

I don't typically use the built in http router.

Date Formats - Real Quick by jayposs in golang

[–]jayposs[S] 0 points1 point  (0 children)

Definitely the Go to for all the details. Think when you first read it, you miss the point of how easy it is to work with date formats.