Migrate a NodeBB forum with MongoDB to Discourse

Rewrited method posts in mongo.rb file

def posts(offset = 0, page_size = 1000)
post_keys = mongo.find(_key: “posts:pid”).sort(score: 1).skip(offset).limit(page_size).pluck(:value)
post_keys.map { |pid| post(pid)}.compact
end

This approach ensures that posts within a topic are sorted in the correct chronological order. Ascending.
Note the sort(score: 1) call .