Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8065895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:48:44+00:00 2026-06-05T11:48:44+00:00

The following two criteria sets give me identical results using Lithium and MongoDB. Both

  • 0

The following two criteria sets give me identical results using Lithium and MongoDB. Both are equally easy to read and write. Should I prefer one over the other for efficiency reasons, or is one just Lithium/MongoDB syntactic sugar for the other?

$criteria = array(
    'fields' => array('_id', 'title', 'created', 'edited', 'username'),
    'order' => {'edited' => 'ASC'},
    'limit' => 3
);

And

$criteria = array(
    '$orderby' => array('edited' => 'ASC'),
    'fields' => array('_id', 'title', 'created', 'edited', 'username'),
    'limit' => 3
);

Follow up question: I really struggled to figure out the right syntax to use for order and $orderby, and in general I find Lithium’s code pretty hard to grok. Do you have any suggestions on how best to approach the codebase for better/faster understanding?

PS: I realise the follow up question might not really be StackOverflow style – but there are other posts on SO and elsewhere which hint at exactly this problem (e.g. Lithium apps that go beyond CRUD). Any input on this could be really valuable!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:48:45+00:00Added an answer on June 5, 2026 at 11:48 am

    Lithium translate 'order' to a MongoBD sort() source

    MongoDB’s $orderby directive is equivalent to calling sort() after a find() source

    So both are equivalent.
    I’ll go with order since it’s a consistent and unified API to interact with any underlying datasource.

    Hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following two functions are extremely similar. They read from a [String] n elements,
I'm fighting about two days with the following problem and hope you can give
I need to replicate the following working HQL query using criteria API. session.CreateQuery( select
When using hibernate criteria just altering the join type affects the results of the
I'm trying to build a query with hibernate criteria for the following scenario: Two
The following two controls on my page: <asp:LinkButton ID=OpenLB runat=server >Open</asp:LinkButton> <asp:HyperLink ID=OpenHL runat=server>Open</asp:HyperLink>
The following two lines of code load an image from an SVG file and
I have the following two chunks of code, I am not so sure what
I have the following two tables in my mysql database. Table Name: groups id
Consider the following two EXPLAINs: EXPLAIN SELECT * FROM sales WHERE title != 'The'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.