querying

Laravel Querying Relations Model::has('relation') doesn't work

谁都会走 提交于 2019-12-12 10:56:24
问题 In the Laravel documentation it says you can use this syntax for querying an object relation to get only the Posts that have at least one Comment: $posts = Post::has('comments')->get(); I'm trying something similar where I want to fetch only objects that have at least one relation object. These are my two classes: class Movie extends Eloquent { protected $table = 'movie'; public function matches() { return $this->hasMany("Match"); } } class Match extends Eloquent { protected $table = 'match';

Is it possible to query for a range of hashes of a hashed indexed key in mongodb?

╄→гoц情女王★ 提交于 2019-12-12 02:48:20
问题 I have a hashed based sharding enabled for a key "userId" in a mongodb collection. Is it possible to get all documents whose hashed values of "userId" are between, let's say, "abcd" and "cdef"? Thanks! 回答1: One way that I found is to use the following query: db.mycollection.find({ "$and": [ {_id: {"$gt": -5012941854059245285}}, {_id : {"$lt": -4712634714892678072}} ]}).hint({_id: "hashed"}) where the long numbers are hashed values of _id. It works for me, but is it the best way of doing so?

PhP (Codeigniter) Merging query results before foreach loop

隐身守侯 提交于 2019-12-12 00:12:23
问题 I would like know if it is possible to merge sql queries like the following from codeigniters active record. //get assigned contacts $this->db->select('*, CONCAT(first_name, " " ,last_name) AS name', FALSE); $this->db->from('customers_contacts'); $this->db->join('customers_accounts', 'customers_accounts.contact_id = customers_contacts.contact_id'); $this->db->like('CONCAT(first_name, " " ,last_name)', $q); $results1 = $this->db->get(); //get non assigned contacts $this->db->select('*, CONCAT

Breaking down a large number of rows into smaller queries? Parallelism

一曲冷凌霜 提交于 2019-12-11 19:52:16
问题 I want to create a external application which will query one table from a large Oracle database. The query will run daily and I am expecting to handle 30,000+ rows. To break down the size of these rows, I would like to create a new thread/ process for each 10,000 rows that exist. So going by the above figure it would be 3 threads to process all those rows. I don't want each thread to overlap each others row set so I know I will need to add a column within the table to act as a range marker, a

Using NOT IN with NOT EQUAL when querying

自作多情 提交于 2019-12-11 15:31:19
问题 I've got a table named "Positions" and I'm trying to get specific information out of. As an example: Position ID Person 4 Joe 5 Mary 4 Mary 6 Shawn 4 Brad 4 Ken 8 Ken Note that a Person can have more than one Position ID. I need to pull out all the names of Persons with a Position Id equal to 4, BUT they also cannot have another Position ID other than 4 as well. I've tried creating a list of all users who have position ID's other than 4, and then saying I don't want any users from that list.

Ontology and the Web

≡放荡痞女 提交于 2019-12-11 12:46:47
问题 I've been having trouble accessing an ontology that we built here via the web. I've been trying to understand sparql and as far as I can tell there's no real PHP support for ontologies yet. I was wondering if I'm going about this right trying to build a java server app that queries the ontology for me that I just access? Or is there an easier better way? Can anyone help with their own knowledge or good references to read? I've been searching and reading for awhile now and can't find much of

Saving and/or Querying User Display Names in Firebase using caseInSensitive?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 18:27:43
问题 I'm moving my project over to Firebase from Swift. Firebase user's don't have usernames but I'm allowing them to save a display name which works more like a attribute than an actual object. How can I get users to query for other users/"friends" using case in sensitive text? 回答1: You can easily accomplish this task. We don't know how your current data is structured but here's an example users user_id_0 dsplay_name: "Smokey" lower_case_name: "smokey" user_id_1 display_name: "Bandit" lower_case

Firestore document references, can you expand the document server side?

落爺英雄遲暮 提交于 2019-12-10 17:55:41
问题 According to this What is firestore Reference data type good for?. Currently it looks like you have to do a round trip to fetch the data for each document reference in your original query. Is this on the roadmap to do this expand/aggregation in the cloud? 回答1: You are correct, a GraphQL style server-side expansion of references is not possible in Cloud Firestore. Completely understand the desire, however this is not currently on our roadmap to support. 来源: https://stackoverflow.com/questions

Rails order by count based on values of column

允我心安 提交于 2019-12-10 10:21:15
问题 Rails 5.1.2 I have a two models Student and Award this way: class Student < ApplicationRecord has_many :awards end class Award < Application Record belongs_to :students # Categories scope :attendance, -> { where(category: 0) } #...(other award categories) scope :talent, -> { where(category: 8) } # Ranks # Gold scope :rank_1, -> { where(rank: 1) } # Silver scope :rank_2, -> { where(rank: 2) } # Bronze scope :rank_3, -> { where(rank: 3) } end Award has these columns: rank and category . Now, I

How to make a query in this nested document structure (MongoDB)?

有些话、适合烂在心里 提交于 2019-12-10 09:17:03
问题 (Sorry if it's a trivial question.) I have documents that looks like this (Python syntax): { '_id': SomeObjectId, 'features': [ {'id': 'featureX' , 'value': 6}, {'id': 'featureY', 'value': 45} ] } With this structure it's easy to find all documents that contains 'featureX' in the list of features. But I'm also interested in retrieving the value associated in the sub-document. I think in Python if I get the document with a query like this: db.articles.find({'features.id': 'featureX'}) then I