Comments (7)
unique_index and index already handle the indexing. any property where these are used are automatically indexed. (Using the equivalent of get_or_create_index_node under the hood)
I had considered supporting default values for properties which could either contain a constant or a function to call.
def uid_generator():
return uid
uid = StringProperty(default=uid_generator, unique_index=True)
This could be used to create a custom UnqiueID property, it's probably worth mentioning that it's easy to subclass the current properties.
I will add in the hook necessary for default values this evening
from neomodel.
Default value is an excellent idea.
Here the point is more to emulate one py2neo function, which is get_or_create indexed node. The point would be that I can do, in my codeclass Place(StructuredNode): name=StringProperty()
Place.get_or_create(name="Home")#first time-> create the nodePlace.get_or_create(nmae='Home')-> node already exist: just send a reference to it
Date: Wed, 31 Oct 2012 08:39:51 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [neomodel] [Feature Request] Smart Creation (#21)
unique_index and index already handle the indexing. any property where these are used are automatically indexed. (Using the equivalent of get_or_create_index_node under the hood)
I had considered supporting default values for properties which could either contain a constant or a function to call.
def uid_generator():
return uid
uid = StringProperty(default=uid_generator, unique_index=True)
This could be used to create a custom UnqiueID property, it's probably worth mentioning that it's easy to subclass the current properties.
I will add in the hook necessary for default values this evening
—
Reply to this email directly or view it on GitHub.
from neomodel.
Hey,
Just pushed support for default values so you can handle uid generation. As it happens we need this feature at work.
What your trying to do with get_or_create is basically the equivalent of:
try:
p = Person.get(name='tim')
except Person.DoesNotExist:
p = Person(name='jim')
Which is not too much longer and very easy to read. The issue with get or create is that each item can have multiple properties in an index as opposed to one. Some of those properties are not necessarily unique.
R
from neomodel.
You're right. Indeed, this try/except should be enough.
Date: Thu, 1 Nov 2012 07:50:35 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [neomodel] [Feature Request] Smart Creation (#21)
Hey,
Just pushed support for default values so you can handle uid generation. As it happens we need this feature at work.
What your trying to do with get_or_create is basically the equivalent of:
try:
p = Person.get(name='tim')
except Person.DoesNotExist:
p = Person(name='jim')
Which is not too much longer and very easy to read. The issue with get or create is that each item can have multiple properties in an index as opposed to one. Some of those properties are not necessarily unique.
R
—
Reply to this email directly or view it on GitHub.
from neomodel.
Just on remark though: unless mistaken, the 'get' method you're suggesting is not existing in my version. Is it something being developped ?
from neomodel.
Ah, there's a '.index' missing there. Should be
Person.index.get(name='test')
On Mon, Nov 5, 2012 at 5:39 PM, opqopq [email protected] wrote:
Just on remark though: unless mistaken, the 'get' method you're suggesting
is not existing in my version. Is it something being developped ?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-10079973.
from neomodel.
Thanks !
from neomodel.
Related Issues (20)
- Provide "light" options for inspection script HOT 1
- Incorrect query for count of objects HOT 2
- AttributeError: 'SpecificNode' object has no attribute 'unique_relation' HOT 2
- Relationship properties marked with db_property are skipped during inflation HOT 1
- Structured Node `__eq__` works incorrectly for non-persisted nodes.
- Unable to access property values on nodes that inherit from SemiStructuredNode HOT 1
- neomodel_inspect_database - Only writes first relationship HOT 2
- Missing import in contrib __init__ HOT 1
- Neomodel trying to connect to localhost, even if the database is on Aura ( When calling NODE_NAME.nodes.all() ) HOT 2
- `UniqueIdProperty` makes `get_or_create()` function does not work as expected HOT 2
- zero or more relationships in either direction of type RELATIONSHIP_NAME on node (4:2c06737f-f675-4209-a253-42d649d5fc59:395) of class 'NODE_LABEL'
- `Database` was removed from `neomodel.util` and moved into `neomodel.sync_.core` HOT 4
- Cant retrieve additional relations using `fetch_relations` HOT 6
- neomodel_inspect_database does not correctly report date property
- async iterating over nodes is not working HOT 5
- neomodel_inspect_database RelationshipTo model as string HOT 1
- Make async iterator fully async
- concurrent async calls of `get_or_create` lead to duplicate nodes HOT 1
- Test integration of cachetools
- Add support for full-text index creation
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 neomodel.