Comments (15)
I'm not sure why the Array type was removed, but I believe it will work if you change type: 'array'
to type: 'object'
.
from model.
Array datatype was kind of superfluous -- and it made the round-trip serialization story simpler just to say "we have all these specific scalar datatypes, and 'object' for anything else."
This was noted in the changelog -- sorry we missed removing it from the list of documented datatypes. I just removed it, and the site should pick up the changes sometime today. Let me know if you see any other references to it floating around. :)
from model.
Hmm, yeah I guess I could do {ids: [123, 345]}
, but how easy is that to query with Mongo or Geddy's adapter? I'm basically using this as a join. A user can have multiple IDs and why i wanted it an array.
group.id = 123 // I get the group ID from some action in the UI, like deleting the group for example
user1.groups = {ids: [123, 456, 789]} // Wrapped in an object since I can't use an array
user2.groups = {ids: [xxx, yyy, 123, zzz]}
Now, whats the easiest way to query "all users part of 123
"? Or am I doing this totally wrong?
from model.
No, you can save any JSONizable object in that datatype. Just declare it as datatype 'object', and save the array like normal.
Any reason not to use the Postgres adapter with eager-fetched associations and do an actual join? :) That's what that's for.
from model.
Do this:
this.defineProperties({
foo: {type: 'object', required: true}
});
// when setting
thing.foo = [id, otherId, etc];
Just call it an object (everything in JS is technically an object), but keep the value as an array.
from model.
@mde Probably because SQL sucks.
from model.
Ah, I see, yeah I thought object
meant a hash :)
@mde I probably will later, but thats why I'm using Geddy. I can build this out as a prototype and then swap out the DB without too much fuss! (well, I hope haha)
from model.
@techwraith You don't have to write any SQL, that's the whole point. :)
from model.
@mde Well, if you only use Geddy to access the data, that's true, but if you ever have to edit data directly in the DB, that's not true. Though I suppose that's what geddy console
is for.
from model.
NOSQL is great for things where you don't want any relationship between pieces of data. @OscarGodson is jumping through extra hoops to make non-relational data relational. If you actually want relationships between things, use a relational database. Then you can get the list of Users, the list of Groups, the list of Users per Group, and the list of Groups per Users. I keep thinking it's weird to see people a non-relational store, and then doing all these weird, hacky things to get relational behavior.
from model.
@mde For this it's just because I'm trying to get a prototype. I'm a noob at SQL and I've never interacted with Postgres directly. I will switch it for sure if it makes it past the prototype stage, but this is basically the only join I need to make for this stage. Geddy just allows me to plug-n-playβ’ DBs so I can put off the SQL learning curve for a bit ;)
from model.
Hello.
I've got a similar, but slightly different problem.
I've got an array to be saved and it's not validating as an object. I'm not sure what other details to provide.
The exact validation error I receive is Tags: "tags" must be an object..
from model.
@raphaeltm Maybe we could start with a Gist of some of the problem code? Where are you setting the value for the tags prop?
from model.
So, I'm new to Node and Geddy and I think I figured it out.
I have a Project model with a property tags: {type: 'object'}
In the "Create" action, after var project = geddy.model.Project.create(params);
, I was converting a string of comma-separated tags from the params and assigning them to project.tags
, like this:
project.tags = project.tagStringToArray(project.tags);
(a method I added to the model for this purpose. it returns the array of tags.)
The PHP frameworks I've used in the past allow this sort of assignment before validation.
With Geddy, it seems that if I use project.updateProperties()
instead, everything works.
Sorry if this was a bit silly. I guess it will take me a little while to figure this all out.
Thanks for the prompt response, though.
from model.
No worries, glad you got it figured out. :)
from model.
Related Issues (20)
- How do I save data to association models? HOT 5
- Null character in text body crashes PG adapter HOT 5
- Data from database different than model returns HOT 6
- Real number not always a good choice. HOT 3
- createdAt and updatedAt HOT 1
- New Eager Loading Bug! HOT 6
- PG Adapter Presently Only Fakes Streaming HOT 7
- TypeError: Cannot call method 'collection' of undefined. HOT 4
- Redis adapter HOT 1
- PG 9.3: ERROR column "foobar.created_at" must appear in the GROUP BY clause or be used in an aggregate function HOT 1
- some questions about update
- Complex query question HOT 1
- why finally sql's tablename have `s`or `es` HOT 1
- Can you only updateProperties per model? HOT 10
- Filter which properties are shown HOT 7
- Rest-adapter: Instance cache lifetime HOT 1
- How to write a custom adapter HOT 1
- cast json fields to string before applying queries
- about `save` method and model's id HOT 3
- Save Method issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from model.