Comments (8)
Thanks for the input and yes, you are correct.
First I was thinking also GetRoot
-method, but because of lack of time, thought that adding functionality to GetItem
would have been the fastest way to implement this. As you pointed out, it wouldn't have even worked that way.
Have to think this littlebit more, but maybe GetRoot
has to return Root
-object that can either have a DocumentCollection
or a single item.
from json-flatfile-datastore.
Hello,
I saw this issue opened and I was wondering whether It has been fixed. If not, I will like to attempt to provide a solution to it
from json-flatfile-datastore.
There is no way to retrieve whole JSON as a document/object.
Root level properties are documents, so if you want to retrieve settings as a single object, you have to put it under property:
{
"settings" : {
"selected_user": { "id": 1, "name": "Phil", "age": 40, "city": "NY" },
"temperature": 23.45,
"note": "this is a test"
}
}
from json-flatfile-datastore.
@ttu Thanks for the response! May I request a feature to retrieve a whole document then? :)
from json-flatfile-datastore.
Yes, I can add it.
How about if I just modify the GetItem-method, so if it is called with empty string as a key, then it would return the whole JSON?
var settings = _ds.GetITem<Settings>(string.Empty);
from json-flatfile-datastore.
@ttu There are 3 points why I think it should be done in a different way:
""
(empty string) - is a valid JSON token's name. In other words{ "": 0 }
is a valid JSON. Hence we have an ambiguation between retrieving""
property and the whole document. Besides it could break backward compatibility.- From the method's name it's unclear that it could be used to retrieve the whole document - by using special values or without them.
- From my point of view It violates SRP: the method is being utilized for two distinct things.
I'd say there should be a dedicated method for getting the whole document. Something like GetRoot
or GetDocument
. GetRoot
seems more appropriate to me because at the outermost level JSON could be an array as well as an object.
from json-flatfile-datastore.
Thanks @AbdulmueezEmiola! This hasn't been fixed/implemented yet. I started some solution, but then forgot this...
Pushed the implementation I had done to https://github.com/ttu/json-flatfile-datastore/tree/add-getroot. Commit: 0258e7e
Based on what you had in mind you can continue that or if you have some better idea, provide a new solution :)
from json-flatfile-datastore.
If someone does provide a solution for this, it would be appreciated if this could be updated. I just started using this today, got it all worked out and implemented, only to find out I could not simply get all records. : /
from json-flatfile-datastore.
Related Issues (20)
- InsertItem gets stuck in .NET Core 3 WPF project HOT 2
- Clarification, not issue HOT 1
- Dynamic update of child items HOT 1
- Using DI with a console app should I inject as singelton or transient? HOT 2
- Index on property HOT 1
- Update function not working HOT 5
- Simple encryption support
- 看到这个我醉了
- No Timeout/Error on file inaccessibility HOT 1
- System.OperationCanceledException When Disposing DataStore HOT 7
- Synchronizing Async Methods HOT 2
- Providing My Own Primary Keys HOT 1
- No Iterator over Collections? HOT 2
- Minified or compact version of JSON possible? HOT 4
- How to get ToList() ? HOT 1
- Add Support for using a directory as the store, with each document within as a child
- Single Item last field gets duplicated on Replace (When upsert: true and field names in Datastore are in camel case) HOT 5
- Support filesystem abstraction HOT 1
- System.Text.Json HOT 2
- Update is not updating the json File HOT 6
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 json-flatfile-datastore.