this post was submitted on 03 Sep 2023
9 points (100.0% liked)

Golang

313 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS
 

Hi,

is there a way to use MongoDB query syntax or something similar to filter arrays/slices or validate data in Go?

In (node)JS there's Sift.js or (less MongoDB style) Underscore/lodash.

Possible use cases:

  • Easily readable validation syntax (at least for people knowing MongoDB)
  • mocking a MongoDB for dev purposes
  • filtering arrays/slices more easily

I'm relatively new to Go so maybe there already is a best practice to do stuff like that, I don't know of.

top 1 comments
sorted by: hot top controversial new old
[–] nnullzz 1 points 1 year ago

Not sure about a MongoDB specific solution but maybe you can use go-funk for filtering slices that’s sort of Lodashish. Could be used as part of a full solution.