Here is an API call I am writing. It works with INTEGER. However in the PostgreSQL DB the Hospital_ID is BIGINT.
desc "All Hospital Locations"
params do
requires :authtoken, type: String, desc: "auth token"
requires :hospitalid, type: Integer, desc: "hospital ID"
#requires :hospitalid, type: Virtus::Attribute::Bigint, desc: "hospital ID"
#Virtus::Attribute::Boolean,
end
I want to be able to pass BIGINT or similar variable.
Related
I'm coding a search function, with users having a username that you can find by searching. I can get users that completely match the string query, but I want to get all users whose username contains the query string I entered.
Here's what I have so far:
paths:
/user:
description: get and create users
get:
description: Get user
parameters:
# something here to get all users whose name includes the query
- in: query
name: studentname
required: true
schema:
type: string
example: Jeffery
responses:
200:
description: Successful!
content:
application/json:
schema:
$ref: '#/components/schemas/students'
I have imported CSV file in Neo4j database. Part of code looks like this:
LOAD CSV WITH HEADERS from "file:///AccountTry.csv" as row
WITH row, split(row.birth_date, '-') as date
CREATE (a:AccountTest {id: toInteger(row.id), account_type: row.account_type, first_name: row.first_name, last_name: row.last_name })
and that works fine. I can see all my nodes and their attributes in neo4j browser.
Then, i created model in rails application:
class AccountTest
include Neo4j::ActiveNode
property :first_name, type: String
property :id, type: Integer
property :last_name, type: String
property :account_type, type: String
end
I made migration and that works fine. When i open rails console and try "AccountTest.first" i get all atributes fine, only property "AccountTest.id: nil".
Why is "id" nil? I have 6 nodes and all of them in rails application have id = nil, but in Neo4j browser all of them have correct ids.
I don't think you need to declare the id property in the AccountTest class. This property is the primary key and is there by default.
As this is an additional property (different form the id generated by Neo4j) I suggest that you rename the property on AccountTest (e.g. account_id) and change the CSV import to load the value into the account_id field.
Let's say I have a user model defined with: id, first_name, last_name, created_at, and I have an object definition for it in swagger.
A POST request to create a user would expect first_name and last_name. How would I write that in swagger? Swagger expects a single object for the Should I create a new object just for the that?
How about
myuser:
allOf:
- $ref: '#/definitions/myuserbase'
- type: object
properties:
id:
description: |
Unique identifier for the classifier.
type: string
example: user1
created_at:
description: |
Date and time the user was created.
type: string
format: date-time
required:
- id
and
myuserbase:
type: object
properties:
first_name:
description: |
First name of the user
type: string
last_name:
description: |
Last name of the user
type: string
required:
- first_name
- last_name
You can mark first_name, last_name as the required fields. Here is an example:
required:
- first_name
- last_name
Ref: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L658-L660
(in other words, no need to create a separate object)
I am developing the application with Ruby on Rail. As in my current project I have an active record model as an example below :
<Site id: 6241, collection_id: 7, name: "ABC", properties: {"31"=>20}>
<Site id: 6242, collection_id: 7, name: "ABC", properties: {"10"=>20}>
<Site id: 6243, collection_id: 7, name: "ABC", properties: {"11"=>30}>
However, I want to find the site which has the properties with the key '31' and value 20, but I cannot find the way to compare this hash attribute. So is there any way you could suggest me?
Also assuming your column type is an hstore, you can just:
Site.where(properties: { key: "value" })
If column type hstore and db postgres you can search by this query:
Site.where("properties #> hstore(?, ?)", 'key', 'value')
I also use mysql and this will work:
Site.where(properties: {"31"=>20}.to_yaml)
I'm new to Symfony and Doctrine and am writing a web app. I added the sfDoctrineGuardPlugin to my project. When I open the schema.yml file for the plugin I see this:
sfGuardUser:
actAs: [Timestampable]
columns:
first_name: string(255)
last_name: string(255)
email_address:
type: string(255)
notnull: true
unique: true
username:
type: string(128)
notnull: true
unique: true
algorithm:
type: string(128)
default: sha1
notnull: true
salt: string(128)
password: string(128)
is_guest:
type: boolean
default: 0
is_active:
type: boolean
default: 1
is_super_admin:
type: boolean
default: false
last_login:
type: timestamp
indexes:
is_active_idx:
fields: [is_active]
relations:
Groups:
class: sfGuardGroup
local: user_id
foreign: group_id
refClass: sfGuardUserGroup
foreignAlias: Users
Permissions:
class: sfGuardPermission
local: user_id
foreign: permission_id
refClass: sfGuardUserPermission
foreignAlias: Users
Does this schema generate a table with a primary key (and if so, how do I access it)? I've looked online and most of the pages that cover the schema for sfGuardUser display an id column that is the primary key. What am I missing? Thanks.
Yes, it's id, accessed as sfGuardUser u --> u.id, as in...
$user = Doctrine::getTable('sfGuardUser')->findOneById(55);
or...
$q = Doctrine_Query::create()
->select('u.*')
->from('sfGuardUser u')
->where('u.id = ?', 55);
$q->execute();
I think somewhere in the Doctrine documentation it says that Doctrine auto-generates an "id" primary key if one isn't declared in the YAML file. It used to be declared explicity in the sfGuardPlugin schema but as of Symfony 1.4.8 (I think), it's just not written.
One thing to watch out for is that elsewhere in your schema, you need to make sure that you declare the same numeric type for the other end of the foreign key relationship or otherwise it'll throw an error. I think it's just type: integer that you need.
If no primary key is given, doctrine will create an id fieldwith type bigint and with a primary key.