Comments (16)
Assuming that there is not another contending name, I prefer "collection" over "container". Container I have mostly seen in a GUI context. It does feel awkward.
from azure-cosmos-js.
Suggested change:
I think it makes sense to allow objects to be able to modify themselves and to create objects that can be self-referencing.
The objects would still be stateless (save for the coordinates from the factory i.e. ids and partition keys)
Examples:
Container
#.database(): Database // point to parent database
#.read(options?: RequestOptions) => Promise<Response<ContainerDefinition>>
#.replace(body: T, options?: RequestOptions) => Promise<Response<ContainerDefinition>>
#.delete(options?: RequestOptions) => Promise<Response<ContainerDefinition>>
Example:
// check if this container has a sibling(s) with a suffix
async function findSiblings(c: Container): Container[] {
const {result: siblings} = await c.database.query(`SELECT * FROM d WHERE STARTSWITH(${c.id})-`).toArray();
return siblings;
}
Item
#.container(): Container // points to parent container
#.read<T>(options?: RequestOptions) => Promise<Response<T>>
#.replace<T>(body: T, options?: RequestOptions) => Promise<Response<T>>
#.delete<T>(options?: RequestOptions) => Promise<Response<T>>
somewhat contrived example:
function getTodoForFutureUpdates(c: Container, todoId: string, userId: string): Item {
return c.getItem(userId, todoId);
}
Stored Procedure
#.container(): Container // points to parent container
#.execute<T>(params: any[], options?: RequestOptions) => Promise<Response<T>>
#.read<T>(options?: RequestOptions) => Promise<Response<T>>
#.replace<T>(body: T, options?: RequestOptions) => Promise<Response<T>>
#.delete<T>(options?: RequestOptions) => Promise<Response<T>>
Current:
c.executeStoredProcedure("fizzbuzz");
c.executeStoredProcedure("fizzbuzz");
Suggested:
(Current continues to work)
const sp = c.getStoredProcedure("fizzbuzz");
sp.execute();
sp.execute();
sp.execute();
from azure-cosmos-js.
Container vs Collection
As a developer, "container" feels awkward to me. I don't know if that's because I'm used to seeing "collection", but I am wracking my brain and I cannot think of any other instances where I have used "container" in a NoSQL context.
from azure-cosmos-js.
re: Container vs Collection - @kirankumarkolli & @kirillg, could you comment?
from azure-cosmos-js.
@burkeholland RE: Container vs Collection
Because we're multi-model, we're starting to rename the base concepts to more generic names, so we're not overloading traditional NoSQL names (Collection/Document/etc.) when we're doing Graph and Cassandra operations on the same data set, in the future.
We could, however, offer a shim or typedef for Collection & Document for folks looking for traditional NoSQL APIs, that are just direct representations of our Container/Item concepts. Do you think that might address your concern?
from azure-cosmos-js.
from azure-cosmos-js.
It's a good question. We'd have to document them both, is my assumption. Same doc or different doc. I'm not sure how/when we're changing our top level messaging/portal UI/etc.
If it's an interesting idea to you, I can work it out with @kirillg in more detail.
from azure-cosmos-js.
from azure-cosmos-js.
It's fair feedback on the naming, though. We've had a few folks mention it. We have good reasons to change the name for other consumers (like Mongo/Gremlin/etc.) to avoid overloading the Document NoSQL stuff for each of them, but that plan does mean impacting the folks using Cosmos for the Document style interaction. I definitely want to see what can be done to prevent this causing confusion.
We're doing user testing with the new names & API style. That will hopefully give us some more feedback in a controlled setting.
from azure-cosmos-js.
Suggestion:
All the .get*(id)
calls should just be called .get(id)
, though they will all defer in which types they return, still.
I think it's self explanatory that databases.get("foo")
will return a database, and it saves on line length/etc.
from azure-cosmos-js.
Suggestion: (Needs more investigation)
Could support a Proxy on the plural objects that have .get
calls that will proxy calls to non-reserved indexes to .get
.
So you can do:
client.databases["foo"].read()
instead of
client.databases.get("foo").read();
It really pays off once you add two layers:
client.databases.foo.containers.bar.items.get("baz","qux")
vs
client.databases.get("foo").containers.get("bar").items.get("baz", "qux")
.get
would still work because Proxy would just proxy to it
Strawman implementation:
type ProxiedDatabases = Databases | [database: string]: Database;
const databases = new Databases(this);
this.databases = new Proxy(databases, {
get: (obj, prop) => obj.get(prop);
Pros:
- Faster to access things
- Avoids overhead of ".get" call
- Matches C# API
Cons:
- Will add overhead to every single call since it has to go through the proxy.
- It's not a well known pattern in JavaScript (Proxy is very new). It might lead to weird things that are hard to explain.
from azure-cosmos-js.
Suggestion:
.get
accepts an id
, but it should also be able to accept an object that has an id property on it
from azure-cosmos-js.
Suggestion:
Things like permissions require a link to a resource. It takes a resource url string, but it should also be able to take an object that has a url
property on it.
from azure-cosmos-js.
👍 to both of @christopheranderson suggestion. I particularly found that overloading .get
would have helped when refactoring the tests.
from azure-cosmos-js.
This was mostly done in #26. Some minor tweaks happened in response to feedback covered in #39.
from azure-cosmos-js.
This feedback has been addressed or moved to independent issues, so I'm closing.
from azure-cosmos-js.
Related Issues (20)
- CosmosClientOptions.connectionPolicy: Nested object retryOptions replaced instead of merged HOT 5
- using dependency that implements "async" HOT 1
- Getting self signed certificate error with local cosmos db emulator HOT 2
- No option to read change feed for a partition key range HOT 1
- Improve out of the box emulator experience HOT 1
- Why retry for error 429 HOT 2
- Additional context/debug information for required retry attempts HOT 2
- Thrown errors in StoredProcedures not reflected in Client HOT 3
- Cannot find name 'AbortSignal' HOT 7
- Backport Cross Partition Query Metrics to v2 HOT 1
- Retry on EPIPE HOT 2
- Sample: Using continuation tokens with stored procs HOT 1
- Await Initial Endpoint Discovery Call
- Backport Retry on EPIPE error to v2 HOT 2
- Type Error for ORDER BY queries where order value is null HOT 1
- Unexpected requestTimeout behavior HOT 3
- Is there a way to set a query timeout? HOT 4
- Support AbortSignal on query operations HOT 1
- Cosmos JS repo is moving HOT 5
- This repo is missing important files
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 azure-cosmos-js.