This post deals with using rethinkdb with python repl
Do your installations
Note: in every python example, I have intended it wrongly for easy reading. Please make it into a single line, before pasting in the Repl. Try typing.
Get the Conn
[]
type Controler struct{ | |
} | |
func c Controller Config() apis.Config{} {} | |
func c Controller BeforeFilters() []actions { | |
if Methdo == "POST" { | |
retuen []actions{} | |
} esles is "PUT" |
def flatten_array(array) | |
flattened_array = [] | |
array.each do |element| | |
if element.kind_of?(Array) | |
flatten_array(element).each do |sub_element| | |
flattened_array << sub_element | |
end | |
else | |
flattened_array << element | |
end |
why you need break and contibue | |
for() { | |
if { | |
break | |
} else { | |
body; | |
} | |
} |
// emphasise on what is what by method | |
softDelete(obj){ | |
update bson.status = "deleted" | |
} | |
hardDelete(obj) { | |
mongo.Delete(obj.ID) | |
} | |
People - soft deleted |
_id, preview_token | |
permalink, preview_token | |
type publicQueryGen bson.M | |
type manageQueryGen bson.M | |
func (qG publicQueryGen) Get(config) ([]Events, error) { | |
var e []Ebvents | |
err := return db(config.DB).C(config.C).Find(qG).All(&e) | |
return e, err |
// model | |
fund getPublicEvents(status, publish_status string, isPrivate bool) | |
EventMeta{} | |
Events { | |
GetALL() []Events | |
} | |
ManageEvent struct{ |
This post deals with using rethinkdb with python repl
Do your installations
Note: in every python example, I have intended it wrongly for easy reading. Please make it into a single line, before pasting in the Repl. Try typing.
Get the Conn
[]
conn = r.connect(host="localhost", port=28015, db="arkinventory", auth_key="", timeout=20) | |
r.table("reportsdata"). | |
concat_map(lambda attendees: [attendees['attendees']]). | |
concat_map(lambda attendees: attendees['attendees']).sample(4).run(conn) | |
r.table("reportsdata"). | |
concat_map(lambda attendees: attendees['attendees']). | |
filter({'ticketId': "ticket-id-4321"}).sample(3).run(conn) | |
# add a string in a field to line number (15) | |
perl -pi -e 'if($.==14){s/\n/\n\/\/ ABC\n/g}if(eof){$.=0}' Makefile.txt | |
# replace regex with environment variable | |
perl -pi -e 's/(([0-9]+.){3}([0-9]+))/'$dIPmysql'/g' t.sh |
func mgoSession() *mgo.Session { | |
uri := "127.0.0.1" | |
if uri == "" { | |
fmt.Println("no connection string provided") | |
os.Exit(1) | |
} | |
sess, err := mgo.Dial(uri) | |
if err != nil { | |
fmt.Printf("Can't connect to mongo, go error %v\n", err) |